Open p9s opened 6 months ago
the seconds args: array('age' => '>'), will change all age column to use '>' operator
age
please try this simple demo here.
➜ demo cat index.php <?php require 'vendor/autoload.php';
ORM::configure('sqlite:./example.db'); ORM::configure('logging', true);
$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' ))
person
name
Yeah that's a different query. Note the extra array with '>' in it?
yes, the ORM final generate SQL is correct. but, in doc write a wrong SQL example. see my pr
the seconds args: array('age' => '>'), will change all
age
column to use '>' operatorplease 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' ANDage
> '10' ) OR (name
= 'Fred' ANDage
> '20' ))