php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #33656 Let PDO::query and PDO::exec accept $input_parameters
Submitted: 2005-07-12 12:04 UTC Modified: 2017-10-24 08:30 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: vrana@php.net Assigned:
Status: Open Package: PDO related
PHP Version: 5.0.4 OS: Irrelevant
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-07-12 12:04 UTC] vrana@php.net
Description:
------------
It will be nice if PDO::query() and PDO::exec() would accept $input_parameters. I like to take advantage of variable binding and I am querying a database with just one set of parameters quite often so the current interface is not very friendly for me.

Reproduce code:
---------------
<?php
foreach ($pdo->query("SELECT name FROM test WHERE name LIKE ?", array($_GET["name"])) as $row) {
   echo "$row[name]\n";
}
?>

Expected result:
----------------
List of names.

Actual result:
--------------
Currently, this code must be used:
<?php
$result = $pdo->prepare("SELECT name FROM test WHERE name LIKE ?");
$result->execute(array($_GET["name"]));
foreach ($result as $row) {
   echo "$row[name]\n";
}
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-30 22:59 UTC] cmb@php.net
-Package: Feature/Change Request +Package: PDO Core
 [2017-10-24 08:30 UTC] kalle@php.net
-Package: PDO Core +Package: PDO related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Aug 21 13:01:35 2019 UTC