j4mie / idiorm

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.
http://j4mie.github.com/idiormandparis/
2.01k stars 369 forks source link

lowercase comparisons #7

Closed hexa2k9 closed 13 years ago

hexa2k9 commented 13 years ago

On MySQL the following Query is possible: SELECT * FROM table WHERE LOWER(field) = 'stringtomatch';

I personally use that A LOT on some webapps .. is there a way for this kind of comparison on idiorm as well? ->select('LOWER(field)', 'stringtomatch') isn't working for me.

The same is for other things like transforming a datetime to a timestamp using UNIX_TIMESTAMP(field).

j4mie commented 13 years ago

Hi,

This is a perfect use case for the where_raw method:

ORM::for_table('table')
    ->where_raw('LOWER(field) = ?', 'stringtomatch')
    ->find_many();
j4mie commented 13 years ago

Oops, forgot to close