j4mie/idiorm — pull request #79 by markchalloner (2012-11-28 10:48:16+00:00)
Title: Emptysetfunction

Hi,

I added a function.

```php
ORM::for_table('people')->none()->find_many();
```

That is guaranteed to return an empty set. This code devolves down to the following query:

```sql
SELECT * FROM `person` WHERE 0;
```

The reasons for having a dedicated function are:

- Syntatic sugar: `none` or a similarly named function makes more sense than `where_raw(0)`
- Possibility to optimise (by not actually executing the query)

An example use of this code in Paris would be:

```php
class User extends Model {

public static function has_cookie($orm, $cookie_name) {
if (isset($_COOKIE[$cookie_name])) {
$cookie = $_COOKIE[$cookie_name];
return $orm->where('cookie', $cookie);
}
// Return empty set
//return $orm->where_raw(0);
return $orm->none();
}

}

$users = Model::Factory('user')->filter('has_cookie', 'user')->find_many();
```