1

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.

0

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.