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

Update querying.rst #378

Open p9s opened 6 months ago

p9s commented 6 months ago

the seconds args: array('age' => '>'), will change all age column to use '>' operator

please try this simple demo here.

➜ demo cat index.php <?php require 'vendor/autoload.php';

ORM::configure('sqlite:./example.db'); ORM::configure('logging', true);

ORM::raw_execute('create table person (id INTEGER PRIMARY KEY, name TEXT, age integer, gender TEXT)');

$people = ORM::for_table('person') ->where_any_is(array( array('name' => 'Joe', 'age' => 10), array('name' => 'Fred', 'age' => 20)), array('age' => '>')) ->find_many(); echo ORM::get_last_query() . "\r\n"; ?> ➜ demo php index.php SELECT * FROM person WHERE (( name = 'Joe' AND age > '10' ) OR ( name = 'Fred' AND age > '20' ))

treffynnon commented 6 months ago

Yeah that's a different query. Note the extra array with '>' in it?

p9s commented 6 months ago

yes, the ORM final generate SQL is correct. but, in doc write a wrong SQL example. see my pr