Как получить строковое значение MongoID с помощью PHP?

После вставки я хочу передать объект клиенту с помощью 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);
10
задан Shakti Singh 22 October 2011 в 17:30
поделиться