$row->units
我使用函数serialize()
=>插入数据库值(数组)[$row->units]
,如何使用unserialize()
in json_encode
with回显它们$row->name
?(在 jQuery 中为 ajax 调用返回发送)
数据库中的列:
$行->单位=>
a:6:{i:0;s:15:"Coffee";i:1;s:14:"Satellite";i:2;s:11:"Game Notes";i:3;s:14:"Internet";i:4;s:10:"Pool";i:5;s:0:"";}
$行->名称=>
George Kurdahi
$query = $this->db->query("SELECT * FROM arraha WHERE name LIKE '%$search%' ORDER BY name asc");
$data = array();
foreach ($query->result() as $row)
{
$data[] = array('name' => $row->name, 'units' => unserialize($row->units)); // Line 22
}
return json_encode($data)
上面代码的错误是:
遇到 PHP 错误
严重性:通知
消息:unserialize() [function.unserialize]:281 字节的偏移 277 处出错
文件名:model.php
行号:22