Hello.
Im trying to get data from a data from my table (named Log), but I need to set some conditions. When I set these conditions, my query doesnt work. I got this error:
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found:1054 Unknown column 'dateStart' in 'where clause'
My Command Model
/** * @return array relational rules. */ public function relations() { return array( 'log'=>array(self::BELONGS_TO, 'Log', 'Log_id'), 'file'=>array(self::BELONGS_TO,'File','File_id') ); }
My Log Model
/** * @return array relational rules. */ public function relations() { return array( 'commands'=>array(self::HAS_MANY,'Command','Log_id'), 'user'=>array(self::BELONGS_TO,'User','User_id') ); }
And my admin action at Log Controller
$date = ''; $dateFormatter = new CDateFormatter('en'); if(!empty($_POST['startdate'])) { $dateDB = implode('-',array_reverse(explode('/',$_POST['startdate']))); $condicoes[] = " dateStart >= '{$dateDB}'"; } $criteria->condition = implode(" AND ",$condicoes); $sort=new CSort('Log'); $sort->applyOrder($criteria); $logList=Log::model()->with('user','commands')->findAll($criteria);
Thnks