j4mie/idiorm — pull request #80 by markchalloner (2012-11-28 11:16:37+00:00)
Title: Added a none function that guarantees an empty set.

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();
```