php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49789 I want to make a query like this "UPDATE class=? WHERE user IN (?)"
Submitted: 2009-10-06 14:52 UTC Modified: 2009-10-06 15:03 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: seniuk01 at yahoo dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.3.0 OS: IRELEVANT
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: seniuk01 at yahoo dot com
New email:
PHP Version: OS:

 

 [2009-10-06 14:52 UTC] seniuk01 at yahoo dot com
Description:
------------
I want to make a query like this "UPDATE class=? WHERE user IN (?)" $sth = $DBH->prepare($query);
try
{
  $sth->execute(array('class1',$an_array));
}
catch(PDOException $e)
{
  die("PDO error: ".$e->getMessage()." (".__FILE__." ".__LINE__.")");
}
So I expect this to work .... but it didn't. :(

Reproduce code:
---------------
---
From manual page: book.pdo
---



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-06 15:03 UTC] sjoerd@php.net
Thank you for your bug report.

The behavior you want is neither supported by prepared statements or by PDO. Also, this is properly documented:

pdostatement.execute.php:
You cannot bind multiple values to a single parameter; for example, you cannot bind two values to a single named parameter in an IN() clause.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 10:01:32 2025 UTC