Search code examples
phpmysqlidiorm

How to use OR in idiorm SQL query in PHP?


I am developing an application using idiorm(https://github.com/j4mie/idiorm) for fetching data from database.

Here is my piece of code:

$messages = Model::factory('Messages')->where('from_user_id','1')->find_many();

I want to include an or statement that where->('to_user_id','1')

How can I put this as an OR statement in my Idiorm query?


Solution

  • This looks like what the manual is telling you to do for an OR condition

    $messages = Model::factory('Messages')
                       ->where_any_is(
                                      array(
                                             array('from_user_id' => 1),
                                             array('to_user_id' => 1)
                                           )
                                      )    
                       ->find_many();