Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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



67.7k
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 ?



114.4k
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.