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);
$reader=$connection->createCommand()
->select('rc_code', 'start_date', 'completion_date', 'percentage', 'est_value', 'cost_to_date', 'program_code')
->from('rpt_bac_status_vw')
->where('in', 'rc_code', $ccList)
->query();
I’m getting the error from the where clause, on the foreach loop. It’s telling me I’m giving an invalid argument.
CDbCommand.php(781)
public function where($conditions, $params=array())
{
$this->_query['where']=$this->processConditions($conditions);
foreach($params as $name=>$value)
$this->params[$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.