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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Apr 25 01:01:30 2024 UTC