D
D
DiIce2016-08-02 09:21:10
PostgreSQL
DiIce, 2016-08-02 09:21:10

How to correctly make a query with the IN operator in PGSQL?

The essence of the problem. There is a code:
$ids = array(123, 321, 456, 654);
\model\table::exec("UPDATE words SET status = 0 WHERE id IN (?);", implode(',', $ids));
base - postgress, language - php
library - activerecord
when executing such a code, it gives an error, the value for the id field is not correct, the id
field is int8, in the $ids array only int
what am I doing wrong and how to do it right?
thank!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
krypt3r, 2016-08-02
@krypt3r

php.net/manual/en/pdostatement.execute.php
Example #5. Executing a Prepared Query Using an Array for an IN Statement

M
Melkij, 2016-08-02
@melkij

Show the SQL, not how you generate it.
Most likely IN ('123,321,456,654'), which, of course, is not a number. The question is not related to pg and only has to do with your access library, how to substitute a list of values ​​into in.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question