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.

How to implement a where in statement in a model?

It seems there is only way to found a where in statement.

<?php $robots = Robots::find("type IN ('virtual', 'mechanical')");

Is there any more graceful way to do this?


You can give a look at the model documentation :


$robots = Robots::query()
    ->where("type = :type:")
    ->andWhere("type IN ('virtual', 'mechanical')")
    ->bind(array("type" => "mechanical"))

You may also use phql :

$phql = "SELECT * FROM Cars WHERE IN (120, 121, 122)";