PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, March 13, 2022

[FIXED] Mongodb and Cakephp $all not searching for more than 1 record

 March 13, 2022     cakephp, mongodb, php     No comments   

Issue

I wanted to find all documents with the id of "1" and "2".

I have this code:

$user = $this->User->find('all', array('conditions' => array('_id' => array('$all' => array('1', '2')))));

When I try to debug $user, it doesn't show anything, But when I try to search for only 1 record like this:

$user = $this->User->find('all', array('conditions' => array('_id' => array('$all' => array('1')))));

it works.

I don't know why its not searching for 2 records.


Solution

I the end, I was able to figure out that I should use "$in" rather than "$all"



Answered By - comebal
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing