Good time of day. There is a function in which I pass an array, the keys of which coincide with the name of the columns in the table. I want to make a request of this type:

$features = Yii::app()->db->createCommand("INSERT INTO tbl_features SET {$feature}"); 

Where

 $feature = [ 'name'=>'color', 'value'=>'black' ] 

when executing this script, I get an error

CDbCommand failed to execute SQL query: SQLSTATE [42000]: Syntax error or access violation: 1064 Syntax; If you’re on the line, you’ll find out what you’re reading.

Tell me what I'm doing wrong

1 answer 1

 $command = Yii::app()->db->createCommand(); $command->insert('tbl_features', $feature); 
  • Thank you very much. Works - Sergiy Dudik