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.

Search in 3 tables

How do i Make a query in Phalcon that search in 3 diffrent tables?


edited Oct '15

If it is a join you are looking to do, you can do it in this manner inside your controller:

$result = $this->modelsManager->executeQuery(
    'SELECT * FROM \Placeholder\Models\ModelOne m1, ' .
    '\Placeholder\Models\ModelTwo m2 ' .
    '\Placeholder\Models\ModelThree m3 ' .
    'WHERE AND' .
    ['id' => $id]

I dont think it can be done with Join..

Yes it can, the code that Tobias posted would result in a Complex Result set - If you call ->toArray() against it, you'll find how the SQL returned is structured.

I think you need something like LEFT JOIN if you are using mysql? Just need to make sure each table has an id each can refer to.