Home » Database » MDB2 » Bug #9332
Customize prepared statement name
Details
| Request #9332 | Customize prepared statement name |
|---|---|
| Submitted | 2006-11-14 17:16 UTC |
| From | kailoran at gmail dot com |
| Status | Open |
| Package | MDB2 |
| PHP Version | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2006-11-14 17:16 UTC] kailoran at gmail dot com
Description:
------------
It would be useful if prepare() took another argument that would be used to name the prepared statement instead of using $this->options['statement_format']. This would allow easy naming of individual statements without having to change the option every time and restoring it back afterwards.
Test script:
---------------
// One way of doing it:
/* in MDB2.php, change default options['statement_format'] to have a placeholder for a string, eg. */
'statement_format' => 'MDB2_STATEMENT%3$s_%1$s_%2$s'
/* change the definition of prepare() */
function &prepare($query, $types = null, $result_types = null, $lobs = array(), $statement_name = '')
/* in the prepare() functions, use the new parameter */
...
$statement_name = sprintf($this->options['statement_format'], $statement_name, $this->phptype, md5(time() + rand()), $statement_name);