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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 18:01:28 2024 UTC