propelorm/Propel — pull request #182 by fzaninotto (2011-11-07 22:39:45+00:00)
Title: Introducing raw conditions

Both `Criteria` and `ModelCriteria` can now use raw conditions with a specific binding type. This is indeed a bugfix for the incomplete support of withColumns in `ModelCriteria::having()`.

Example usage can be seen in the added unit tests (to be documented):

```php
where('LOCATE(\'foo\', b.Title) = ?', true, PDO::PARAM_BOOL)
->find();
// SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID
// FROM `book`
// WHERE LOCATE('foo', book.TITLE) = true

// using raw condition on having()
$books = BookQuery::create()
->withColumn('SUBSTRING(Book.Title, 1, 4)', 'title_start');
->having('title_start = ?', 'foo', PDO::PARAM_STR)
->find();
// SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID,
// SUBSTRING(book.TITLE, 1, 4) AS title_start
// FROM `book`
// HAVING title_start = 'foo'
```

The patch would gain to decouple more the raw logic from the model logic, but that would require a deeper refactoring, and I'm not sure we want that in 1.x.