To be more clear with my question, I know that there is yii\db\Command and bindValue() and bindParam() methods, but I’m looking at possibility to have ActiveRecord do it by itself. I don’t want to write all queries manually, but to use builtin functions.
class User extends \yii\db\ActiveRecord{
public static function tableName(){
return 'user';
}
public function rules(){ ... }
}
...
$user= new User();
$user->firstName='John';
$user->lastName='Doe';
$user->save();
When I look at SQL that is being executed after calling $model->save() I see plain SQL statements like
[yii\db\Command::execute] INSERT INTO user (firstName, lastName,...) VALUES ('John', 'Doe', ...)
The same applies to select statements:
[yii\db\Command::query] SELECT * FROM user WHERE id=23
I would expect that framework should create prepared statements and bind parameters.That would be mush faster.
Is there a way to force it to make prepared statements instead of plain SQL?
I made same question on stackowerflow , but I hope that someone from community would provide good answer.