Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Call to a member function getConditions() on a non-object #9

Closed
josemartinez opened this issue Jan 3, 2011 · 3 comments
Closed

Call to a member function getConditions() on a non-object #9

josemartinez opened this issue Jan 3, 2011 · 3 comments

Comments

@josemartinez
Copy link

I'm wondering if its a bug or not, because you dont find without criteria but...

On EMongoDocument.php file line 670 you have

"public function find($criteria=null)"

then you do:

"$criteria->getConditions()"

if criteria is null you get an error. Maybe check if its null before getConditions?

@canni
Copy link
Owner

canni commented Jan 3, 2011

I cannot reproduce this error :/ it works for me

$criteria variable in that line, should be populated with EMongoCriteria object by a applyScopes() method, witch is called with reference to parameter (Original Yii AR class doest the same trick, with applyScopes method)

@josemartinez
Copy link
Author

Happy new year U2!
yes, you are right! I explain you a little what i did.

I changed on my web application from MySQL to full MongoDb. So i have lines as:

UsersDb::model()->find('LOWER(userLogin)=mylogin');

Obviously thats wrong because this request in MongoDb is not correct, but even if its not correct, with this request i do applyScopes with a string as $criteria (thats why $criteria->getConditions() crashes), and i thought you should catch this case.... but i'm wrong because we will not check in this function each type or developement errors..... if we send something different than an array or EMongoCriteria to applyScopes function, is a developper issue, not a conception issue (he should read the doc)

I hope i'm clear!

@canni
Copy link
Owner

canni commented Jan 4, 2011

OK, now I see, I've added a consistence check to applyScopes() method, in commit b38fd19 It will be helpful in case of porting apps to the MongoDB.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants