Search by foreign keys


Can you tell if i can search by a foreign key with find() method ? Or i should create a custom query for that ?


You can use a query builder for that:

$robots = $this->modelsManager->createBuilder()
                ->where('Parts.type <> "some-type"');


Thank you. In my app i have to run complex queries, and i think i will choose to write them plain. What would be a good practice to run complex queries in models, without using directly the pdo ?

Now i have something like:

    $db = $this->getDI()->get('db')->getInternalHandler();
    $s_query = '...';
    $result  = $db->query($s_query);

    return $result->fetchAll();

PS: I think it would be nice and helpful to have a section in the documentation, like "Good practices"