Home » Database » MDB2 » Bug #10007
Restore parameter support for query() and exec()
Details
| Request #10007 | Restore parameter support for query() and exec() |
|---|---|
| Submitted | 2007-02-02 06:14 UTC |
| From | elandril at gmail dot com |
| Assigned | quipo |
| Status | Wont fix |
| Package | MDB2 |
| PHP Version | Irrelevant |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2007-02-02 06:14 UTC] elandril at gmail dot com
Description:
------------
In the former DB package both the query() and exec() methods had an embedded support for parameters, so that you could avoid doing all the statement creation stuff for queries that just need to be executed once. This was especially handy for queries with lots of parameters.
The new approach as it is outlined in the documentation is either to completely prepare the sql statement yourself using the quoting functions (which is a major pain) or to use a statement for every single query (which is also a pain). Especially the migration of some projects gets greatly hindered by this change!
So please bring back the support for parameters in the query() and exec() methods!
Test script:
---------------
In DB you could do something like this:
$res = $db->query('SELECT * FROM table WHERE cond1 = ? AND cond2 = ? AND cond3 = ?', array(10,20,30));
In MDB2 you have 2 possibilities:
1. self quoting, which gets very ugly:
$res = $mdb2->query('SELECT * FROM table WHERE cond1 = ' . $mdb2->quote(10,'integer') . ' AND cond2 = ' . $mdb2->quote(20,'integer') . ' AND cond3 = ' . $mdb2->quote(30,'integer'));
2. preparing a statement, which is painful for migration:
$sth = $mdb2->prepare('SELECT * FROM table WHERE cond1 = ? AND cond2 = ? AND cond3 = ?', array('integer','integer','integer'), true);
$res = $sth->execute(array(10,20,30));