Could you please tell me if it's possible to use numberic field names in mongodb, something like this: {"1" : 'value1', "2" : 'value2', "3" : 55}. It looks like I can input such data using mongodb command line, but I have problems when I try to write such data using php, getting Message: field names must be strings error.
I found about naming of collections in mongodb here http://www.mongodb.org/display/DOCS/Collections, but I didn't find info about naming of fields names. Thank you.
I tried this one for arrays in php:
$elements[1] = 1;
$index = "2";
settype($index, "string");
$elements[$index] = 2;
$elements["3"] = 3;
var_dump($elements);
And it displays:
array
1 => int 1
2 => int 2
3 => int 3
The error I talk about is:
An error occurred Application error Exception information:
Message: field names must be strings Stack trace:
#0 C:\library\Shanty\Mongo\Collection.php(376): MongoCollection->find(Array, Array)
#1 C:\git_reps\mailable\application\models\Subscriber1.php(191): Shanty_Mongo_Collection::all(Array, Array)
#2 C:\git_reps\mailable\application\models\Subscriber1.php(203): Model_Subscriber1::getCursor(Array, Array, Array)
#3 C:\git_reps\mailable\application\controllers\ListsController.php(639): Model_Subscriber1::getPaginator(Array, Array, Array)
#4 C:\library\Zend\Controller\Action.php(513): ListsController->view1Action()
#5 C:\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('view1Action')
#6 C:\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#7 C:\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#8 C:\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#9 C:\git_reps\mailable\public\index.php(25): Zend_Application->run()
#10 {main}
Request Parameters:
array (
'controller' => 'lists',
'action' => 'view1',
'module' => 'default',
'id' => '52',
)
It happens when I try to get mongodb cursuro setting fields something like "1".