Answer the question
In order to leave comments, you need to log in
Is it possible to create an entry in the database using yii\db\ActiveQuery in Yii2?
Hello, is it possible to create a record in the database in Yii2 without using ActiveRecord, only using yii\db\ActiveQuery?
The task is to get rid of the direct SQL query in the code. ActiveRecord for this table cannot be created for some other reason
Answer the question
In order to leave comments, you need to log in
ActiveQuery is an ActiveRecord query parameter management. So it won't work.
But why QueryBuilder does not suit you?
Quote from documentation :
// INSERT
$connection->createCommand()->insert('user', [
'name' => 'Sam',
'age' => 30,
])->execute();
// INSERT multiple rows at once
$connection->createCommand()->batchInsert('user', ['name', 'age'], [
['Tom', 30],
['Jane', 20],
['Linda', 25],
])->execute();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question