完成插入后,我想使用 json_encode() 将对象传递给客户端。问题是,_id 值不包括在内。
$widget = array('text' => 'Some text');
$this->mongo->db->insert($widget);
If I echo $widget['_id'] the string value gets displays on the screen, but I want to do something like this:
$widget['widgetId'] = $widget['_id']->id;
So I can do json_encode() and include the widget id:
echo json_encode($widget);