I am trying to change a mysql_query statement that has the following in PDF:
< Code> $ string = '2, 3, 4, 5, 7, 8';
mysql_query ("... IN ($ string) ...");
It works properly
mysql_query statement, but it will not work with the PDO preparation and execution (no results have been returned).
What am I missing here?
If the query works well with SQL
mysql_query Will work fine with.
Will not work if you tie the whole string with just one placeholder. You need to bind each value for the
IN section.
Example:
$ string = '2, 3, 4, 5, 7, 8'; $ Params = Explosion (',', $ string); $ Sth = $ pdo- & gt; Ready (include '... IN ('. ',' Array_fill (0, count ($ params), '?')). '' ... ...); $ Ret = $ sth- & gt; Execute ($ params);
Comments
Post a Comment