php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53657 Make at least PDOStatement::bindValue and PDOStatement::bindParam() chainable!
Submitted: 2011-01-05 19:33 UTC Modified: 2011-01-06 11:26 UTC
From: schindhelm at gmail dot com Assigned:
Status: Wont fix Package: *Database Functions
PHP Version: 5.3.4 OS: any
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: schindhelm at gmail dot com
New email:
PHP Version: OS:

 

 [2011-01-05 19:33 UTC] schindhelm at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/pdostatement.bindvalue
---

The PDOStatement::bindValue and PDOStatement::bindParam methods should be chainable. Look at my test script below for an example.

Test script:
---------------
// create a new PDO
$dbh = new PDO($dsn, $user, $pass);

// the example SQL statement
$sql = "INSERT INTO db.table (id, firstName, lastName) VALUES(NULL, :firstName, :lastName)";
$statement = $dbh->prepare($sql);

// current behaviour
$statement->bindValue(':firstName', 'Foo');
$statement->bindValue(':lastName', 'Bar');
// and so on...
$statement->execute();

// what I wish for and what saves a lot of copy & paste, but especially time
$statement->bindValue(':firstName', 'Foo')
          ->bindValue(':lastName', 'Bar');
          ->execute();


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-06 03:01 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 [2011-01-06 03:01 UTC] aharvey@php.net
The bind methods already have defined return values. I don't see any
benefit to breaking backward compatibility for such a minor potential
gain.
 [2011-01-06 11:26 UTC] uw@php.net
Use: execute(array(values))
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 10:01:28 2024 UTC