php - How to pass variable in find using cakephp and mongo -


i have problem. before, using mysql in cakephp application. how search in database pretty easy like:

 $user = $this->user->find('first', array('conditions' => array('id' => $id))); 

but when started using mongodb, cannot use $id anymore.

i tried querying:

$id = 1; $user = $this->user->find('first', array('conditions' => array('id' => $id))); // query wont work  $id = '1'; $user = $this->user->find('first', array('conditions' => array('id' => $id))); // work 

i have contain value in apostrophe's. in application, use session variables not contain apostrophe's.

how make variables not contain apostrophe's , still make queries work.

should have '_id' instead of normal 'id'.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -