Cdbcommand->Where Needs Associative Array?

This is my first project using Yii, and I’m really happy with it so far.

I’m building up a query using the Query Builder syntax, and I’m getting an “Invalid argument supplied for foreach()” when I add a ->where() command.

Here’s the code that’s generating the error:

$ccList = array(871210, 871230, 871260, 871310, 871330, 871350, 871370);


   ->select('rc_code', 'start_date', 'completion_date', 'percentage', 'est_value', 'cost_to_date', 'program_code')


   ->where('in', 'rc_code', $ccList)


I’m getting the error from the where clause, on the foreach loop. It’s telling me I’m giving an invalid argument.


public function where($conditions, $params=array())




   foreach($params as $name=>$value)


   return $this;


So do I need to declare $ccList as an associative array? According to the docs I’m using the proper syntax for the IN field.

Any help or suggestions would be greatly appreciated.

[color="#006400"]/* Moved from "Bug Discussions" to "General Discussion for Yii 1.1.x" */[/color]

Hi Tomcdona, welcome to the forum.

The right syntax is:

   where(array('in', 'rc_code', $ccList))

Thanks Softark, I read that wrong.

Sorry for the confusion, and thanks for the quick response!