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
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: 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

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-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 28 18:01:24 2020 UTC