Yii Error Message: column name must be either a string or an array

Yii Error Message: column name must be either a string or an array

Last updated:

You might get this error message if you try to delete a CActiveRecord model with composite primary keys.

You'll need to override primaryKey() method on the model class and make it return the actual primary keys as an array:

class Job extends CActiveRecord {
    public function primaryKey() {
        return ['employee_id', 'company_id'];
    }
//...rest of your class code

If you don't like that you can also add a single primary key (in addition to the attributes you've already got) so that Yii will use that key instead of the other attributes.

Dialogue & Discussion