简体   繁体   English

MySQL查询的结果有限

[英]Results of MySQL Query limited

I try to get a RESTApi with php ans MySQL running and I got pretty far. 我尝试在运行php ans MySQL的情况下获得RESTApi,但我走得很远。 I'm more a Frontend guy so maybe you can help me figure this out. 我更是一个前端人员,所以也许您可以帮助我解决这个问题。 My code is this: 我的代码是这样的:

$sql = 'SELECT * FROM op_content';
$connection = new PDO(DB_CONN, DB_USERNAME, DB_PASSWORD);
$query = $connection->prepare($sql);
$query->execute();

$result = array();

    if ($query->rowCount() > 0) {
        while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
            $result[] = $row;
        }

        $this->response($this->_toJson($result), 200);
    } else {
        $this->response('', 204);
    }

private function _toJson($data) {
    return is_array($data) ? json_encode($data) : '';
}

I dont get any results back from this, only if I add LIMIT 7 (Limit hast to be <= 7) to the SQL-Query. 仅当我在SQL查询中添加LIMIT 7 (限制必须为<= 7)时,我才能从中获得任何结果。 Are there any server-side limits (working on XAMPP atm) or where can that come from? 是否存在任何服务器端限制(在XAMPP atm上运行)或该限制来自何处?

Edit: 编辑:
Playing around a little bit I found out that I can return the results as XML (all of them), is there any reason this does not work with json? 玩了一会儿,我发现我可以将结果以XML格式返回(全部返回),是否有任何理由不适用于json?

OK, I finally figured it out. 好,我终于明白了。 Since I'm from Germany we use umlauts, and altough I got back utf8, somehow it didnt really work, so I had to encode it first. 由于我来自德国,因此我们会使用变音符号,尽管如此我还是回来了utf8,但由于某种原因它并没有真正起作用,因此我必须先对其进行编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM