On Fri, Aug 06, 2004 at 01:38:48PM +0100, Alan Burlison wrote:
> I want to use the DBD::mysql 'mysql_use_result' attribute to make the
> driver use mysql_use_result instead of mysql_store_result, and I want to
> do it for all the queries I'm submitting against the database. Having
> to set it on each and every statement handle that I generate is a real
> pain, I'd like to be able to set the default on the database handle and
> have it inherited by all the statement handles that are generated from
> the database handle.
>
> I'm not sure of the best way to go about this, there are two options:
>
> 1. Store the value in the DBH and copy into the STH when the STH is
> created, unless the STD constructor is given an explicit value.
>
> 2. Store the value in the DBH and each time the STH is executed, look up
> the value in the parent DBH if the STH doesn't have an explicit value.
It was already implemented in my tree with the same behaviour as for
'mysql_server_prepare' attribute:
- attribute 'mysql_use_result' on dbh level, this allows to
enable/disable mode for all new statements:
- DBI->connect("DBI:mysql:test;mysql_use_result=1", "root", "");
- $dbh->{'mysql_use_result'}=0; #disable
$dbh->{'mysql_use_result'}=1; #enable
When new sth is created we set default value of attribute
'mysql_use_result' from $dbh. One can override the default
value:
- $sth=$dbh->prepare(statement, {'mysql_use_result' => 1});
- $sth->{'mysql_use_result'}=0; #disable
$sth->{'mysql_use_result'}=1; #enable
--
Mr. Alexey Stroganov
Full-Time Benchmarks Developer
MySQL AB, www.mysql.com