Lukas Hansen Tue Aug 26 05:16:46 -0400 2014

Subject: Using an array as arguments for condition when using finders

Hi all.
I've got a pretty simple problem, but I just don't know how to fix it.

A working static finder would look like this.
$houses = Houses::all(array('conditions' => array('age >= ? && gender ?', 12, 'male')));

now, what I would like to do is give the function an array with conditions, and one with associated value. something like this

$conditions = "age >= ? && gender ?";
$vals = array(12, 'male');
$houses = Houses::all(array('conditions' => array($conditions, $vals)));

This does't work because it thinks the array of values is an argument to the first condition, so it gives me an error telling me I've got no value to the 2nd condition.

I hope you can help me out. It seems simple, but I just can't find the answer.

It should me noted that the code is not actual code, but just some quick c/p with edits to make it more readable and understandable. The problem is not with the code, so it shouldn't matter too much

cheers