We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Model Name in Find Function

I want to use another model inside find function like: $conditions = ["id" = $id] Model A::find([ 'conditions' => 'id=:id: AND Model B.created_at Between datefrom AND dateto', 'bind' => $conditions, ]);

Any one can help as soon as possible



85.5k
edited Jan '16

i remember older posts , and between was a bit scrwed in the parser ( i am not 100% sure ) use


id bla bla ... AND  Model_b.created_at >= |XXX| AND model_b.created_at <= |XXX| 

but i am not sure what your problem is ? You did not explain it i think ?



145.0k
Accepted
answer
edited Jan '16

Use modelsManager for that(joins) or native query if you need to subquery from other table. Model find/findFirst methods are mostly for select without assosciated data, I at leasy use it like this.

Thanks Jurigag I have used model Manager which give me same array as find function gives.

Use modelsManager for that(joins) or native query if you need to subquery from other table. Model find/findFirst methods are mostly for select without assosciated data, I at leasy use it like this.