我遇到了一个使用json_encode显示JSON的问题。问题是在某个点之后它被截断了,我猜测在2500行左右。我读了很多stackoverflow和其他网站上的q&a,建议增加内存限制。我已经将其增加到32m,但它仍然被截断,而且我认为这不是问题,因为我已经输出了内存使用情况,并且使用true时我得到3.5mb,使用false时我得到1.5mb。我还尝试过将其编码为1000,但直到某个点它仍然会被截断。
我的JSON看起来像这样:
{"Id":"1"},{"Words":""},{"Position":"0"},{"Length":"0"},{"Pdf_Id":"1"}
再有2000行。
我的代码大致如下:
JSON文件
我的JSON看起来像这样:
{"Id":"1"},{"Words":""},{"Position":"0"},{"Length":"0"},{"Pdf_Id":"1"}
再有2000行。
我的代码大致如下:
JSON文件
echo json_encode(array_values($db->getallqueryjsoncountStart("words_table","Allwords",4000,0)));
public function getallqueryjsoncountStart($table,$jsonparentname,$count,$start)
{
$this->sqlquery = "select * from $table LIMIT $start,$count";
$this->stmt = $this->conn->query($this->sqlquery);
for ($i = 0; $i < $this->stmt->columnCount(); $i++) {
$col = $this->stmt->getColumnMeta($i);
$columns[] = $col['name'];
}
$this->initcnt = 0;
$getqueryJson = array();
while($this->row = $this->stmt->fetch())
{
for($x = 0;$x < sizeof($columns);$x++)
{
$getqueryJson[][$columns[$x]] = $this->row[$columns[$x]];
}
}
return $getqueryJson;
}
json_last_error()
的输出是什么?http://php.net/manual/en/function.json-last-error.php - robbmj