Reputation: 673
I'm using https://github.com/j4mie/idiorm and query DB like this:
$result = ORM::for_table('users')->join('messages', array('users.uid', '=', 'messages.uid'))->where('mid', '5')->find_many();
and now i wanna to add a condition:
$result = ORM::for_table('users')->join('messages', array('users.uid', '=', 'messages.uid'));
if(true) {
$result->where('mid', '5');
}
$result->find_many();
However it doesn't work.
Upvotes: 1
Views: 80
Reputation: 3065
Expanding on air4x's comment:
The interface to these methods is considered "fluent" or "fluid" because they return themselves (so the join()
function returns the ORM object with the join embedded in it, instead of say, returning true
or false
)
$result->where('mid, '5');
..will set the where
but then the object is discarded.
$result = $result->where('mid', '5');
..will save the modified object.
Upvotes: 2