Dopo aver fatto un inserto, voglio passare l'oggetto al client usando json_encode(). Il problema è che il valore _id non è incluso.Come si ottiene il valore di stringa di un MongoID utilizzando PHP?
$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);
Riferimento qui: http://php.net/manual/en/class.mongoid.php. Preferirei il typecast (stringa) sotto di me ma al momento della domanda stavo usando il metodo descritto nei documenti. –