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

How can I write this query using Idiorm? #274

Closed periyasamy25 closed 8 years ago

periyasamy25 commented 9 years ago

How can I write this query using Idiorm?

SELECT * FROM table
WHERE (column1 LIKE '%value%' OR column2 LIKE '%value1%') 
  AND column3='value3'
ORDER BY column1 ASC
periyasamy25 commented 9 years ago

Please tell me how to write the above query in Paris.

Isotab commented 9 years ago

This was just a small change from something copied from the docs. Unfortunately I cannot run a local server on my machine right now to test but that should work.

$results = ORM::for_table('table')
            ->where_raw('(`column1` LIKE ? OR `column2` LIKE ?)', array('%value1%', '%value2%'))
            ->where('column3', 'value3')
            ->order_by_asc('column1')
            ->find_many();