Answer the question
In order to leave comments, you need to log in
How to write insert via QueryBuilder >_
I am trying to make a banal insert according to the documentation
Here is my piece of code
$query = \Yii::$app->db->queryBuilder;
$query->insert('poll_vote', [
'choice_id' => $choiceID,
'poll_id' => $pollID,
'user_id' => empty($userID) ? NULL : $userID,
'ip' => $ip,
'timestamp' => time()
], $params);
Answer the question
In order to leave comments, you need to log in
the content received from the user must be bound using prepared statements
$query = new Query();
$query->createCommand()->insert(self::tableName(),[
'choice_id' => ':choiceID'
...], [
':choiceID' => $choiceID
])->execute();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question