PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » MDB2 » Bug #9332

Customize prepared statement name

Details

Request #9332Customize prepared statement name
Submitted2006-11-14 17:16 UTC
Fromkailoran at gmail dot com
StatusOpen
PackageMDB2
PHP VersionIrrelevant
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);