php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50574 PDO prepared statement failed with UPDATE and WHERE conditions
Submitted: 2009-12-25 16:21 UTC Modified: 2009-12-25 16:41 UTC
From: ajulien at gmail dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.2.12 OS: OSX 10.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ajulien at gmail dot com
New email:
PHP Version: OS:

 

 [2009-12-25 16:21 UTC] ajulien at gmail dot com
Description:
------------
A simple prepared statement will fail with « bind or column index out of 
range » in some cases

Reproduce code:
---------------
$prep = $db->prepare('UPDATE "users" SET "force" = ? WHERE ( "user" = ? )');

$prep->execute(array('bar','foo'));

Expected result:
----------------
The update should be executed

Actual result:
--------------
« bind or column index out of range »

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-25 16:41 UTC] ajulien at gmail dot com
Sounds like the bug is else where because this works : 

<?php

$db = new PDO('sqlite:foo.sqlite');
$db->query("DROP TABLE users");
$db->query("CREATE TABLE users (user MEDIUMTEXT ( 255 ), level INTEGER 
( 2 ))");
$db->query("INSERT INTO users VALUES('foobar',2)");
$db->query("INSERT INTO users VALUES('John Doe',2)");
$db->query("INSERT INTO users VALUES('John Doe',2)");

$prep = $db->prepare('UPDATE "users" SET "level" = ? WHERE "user"= ? 
');
var_dump($prep);
$prep->execute(array('99','foobar'));
var_dump($db->errorInfo());

?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC