j4mie/idiorm — pull request #200 by lrlopez (2014-05-18 18:33:21+00:00)
Title: New feature: Multiple OR'ed conditions

Multiple OR'ed conditions
--------------------------------

You can add simple OR'ed conditions to the same WHERE clause using ``where_any_is``. You should specify multiple conditions using an array of items. Each item will be an associative array that contains
a multiple conditions.

```php

where_any_is(array(
array('name' => 'Joe', 'age' => 10),
array('name' => 'Fred', 'age' => 20)))
->find_many();

// Creates SQL:
SELECT * FROM `widget` WHERE (( `name` = 'Joe' AND `age` = '10' ) OR ( `name` = 'Fred' AND `age` = '20' ));
```

By default, it uses the equal operator for every column, but it can be overriden for any column using a second parameter:

```php

where_any_is(array(
array('name' => 'Joe', 'age' => 10),
array('name' => 'Fred', 'age' => 20)), array('age' => '>'))
->find_many();

// Creates SQL:
SELECT * FROM `widget` WHERE (( `name` = 'Joe' AND `age` > '10' ) OR ( `name` = 'Fred' AND `age` > '20' ));
```

If you want to set the default operator for all the columns, just pass it as the second parameter:

```php

where_any_is(array(
array('score' => '5', 'age' => 10),
array('score' => '15', 'age' => 20)), '>')
->find_many();

// Creates SQL:
SELECT * FROM `widget` WHERE (( `score` > '5' AND `age` > '10' ) OR ( `score` > '15' AND `age` > '20' ));
```