V
V
vadim_tur2016-04-15 17:48:30
Yii
vadim_tur, 2016-04-15 17:48:30

Sql IN statement in yii2 prepared query?

Hello. There is an array of id, I want to substitute them in the query UPDATE `table` SET `status` = 0 WHERE id IN (: id). If I give the :id parameter a list of id separated by commas (152, 183, 195), the request affects only the first id.
A passing question: how to view the sql query that eventually turned out. Previously, I did not need it, but now it's interesting to see.
PS: of course, if you substitute parameters directly into sql, then there are no problems, but you don’t want to neglect security.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kim, 2016-04-15
@kimono

The syntax is something like this:
createCommand ()->updateAll ('table', ['status' => 0], ['id' => [152, 153, 185])

T
trevoga_su, 2016-04-15
@trevoga_su

how to view the sql query that eventually turned out. I didn't need it before.
that's why all these PDOs of yours are a fierce dull shit that is impossible to work with.
www.database.phpinfo.su

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question