[PHP-DB] PDO prepared statements and value list for MySQL "IN"

2008-07-08 Thread TK
I'd like to use a PDO prepared statement to perform a MySQL query that uses the IN function. I.e.: $stmt = $pdo->prepare(' select * from mytable where myfield IN (:contents) ); $stmt->bindValue(':contents', $contents); $stmt->execute(); Here's the problem: If $contents is set to a sing

Re: [PHP-DB] PDO prepared statements and value list for MySQL "IN"

2008-07-08 Thread Philip Thompson
On Jul 8, 2008, at 11:55 AM, TK wrote: I'd like to use a PDO prepared statement to perform a MySQL query that uses the IN function. I.e.: $stmt = $pdo->prepare(' select * from mytable where myfield IN (:contents) ); $stmt->bindValue(':contents', $contents); $stmt->execute(); Here's the

Re: [PHP-DB] PDO prepared statements and value list for MySQL "IN"

2008-07-08 Thread TK
At 04:16 PM 7/8/2008, Philip Thompson wrote: >On Jul 8, 2008, at 11:55 AM, TK wrote: > >>I'd like to use a PDO prepared statement to perform a MySQL query >>that uses the IN function. >> >>I.e.: >>$stmt = $pdo->prepare(' >> select * >> from mytable >> where myfield IN (:contents) >>); >>$stmt-

Re: [PHP-DB] PDO prepared statements and value list for MySQL "IN"

2008-07-09 Thread Thodoris
At 04:16 PM 7/8/2008, Philip Thompson wrote: On Jul 8, 2008, at 11:55 AM, TK wrote: I'd like to use a PDO prepared statement to perform a MySQL query that uses the IN function. I.e.: $stmt = $pdo->prepare(' select * from mytable where myfield IN (:contents) ); $stmt->bindValue(':cont

Re: [PHP-DB] PDO prepared statements and value list for MySQL "IN"

2008-07-09 Thread TK
At 03:21 AM 7/9/2008, Thodoris wrote: >At 04:16 PM 7/8/2008, Philip Thompson wrote: >>>On Jul 8, 2008, at 11:55 AM, TK wrote: I'd like to use a PDO prepared statement to perform a MySQL query that uses the IN function. I.e.: $stmt = $pdo->prepare(' select * from myt

Re: [PHP-DB] PDO prepared statements and value list for MySQL "IN"

2008-07-10 Thread Thodoris
O/H TK ??: At 03:21 AM 7/9/2008, Thodoris wrote: At 04:16 PM 7/8/2008, Philip Thompson wrote: On Jul 8, 2008, at 11:55 AM, TK wrote: I'd like to use a PDO prepared statement to perform a MySQL query that uses the IN function. I.e.: $stmt = $pdo->prepare(' select * fro

Re: [PHP-DB] PDO prepared statements and value list for MySQL "IN"

2008-07-10 Thread TK
At 05:53 PM 7/8/2008, TK wrote: >>>I'd like to use a PDO prepared statement to perform a MySQL query >>>that uses the IN function. I may have found my answer (in the PHP manual, under PDO->prepare(). Go figure!): "You cannot bind multiple values to a single named parameter in, for example, t

Re: [PHP-DB] PDO prepared statements and value list for MySQL "IN"

2008-07-10 Thread TK
At 03:23 AM 7/10/2008, Thodoris wrote: >Why don't you work this around. Since you may do anything with strings in php >using the (.) operator try this: > >$a = array('string1','string2'); >$str = implode("','",$a); >$str = "'".$str."'"; >print $str; >?> Thanks, but this is missing the entire poin

Re: [PHP-DB] PDO prepared statements and value list for MySQL "IN"

2008-07-10 Thread Dee Ayy
As you already know, you will dynamically create the $contents. See if you can dynamically create the entire prepare statement which includes the $contents, as well as dynamically create the bindValue statement; then see if you can "eval" those dynamically created statements. $commandPrepare = '$