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.
> 
> e.g. given:
> 
> $dbh->{mysql_use_result} = 1;
> my $sth = $dbh->prepare(...);
> $dbh->{mysql_use_result} = 0;
> 
> under option 1, when $sth is executed the value of the mysql_use_result 
> attribute will be 1, and under option 2 it will be 0.

Use option 1.

So the code in dbd_st_prepare would look like:

  imp_sth->use_mysql_use_result = svp ? SvTRUE(*svp) : imp_dbh->use_mysql_use_result

> One other question - how do I get the parent DBH from a STH from within 
> the XS code for a DBD driver?

Anywhere there's an imp_sth in scope you can declare a imp_dbh this way:

   D_imp_dbh_from_sth;

That's a macro that expands to D_imp_from_child(imp_dbh, imp_dbh_t, imp_sth).
[Which expands to imp_dbh_t *imp_dbh = (imp_dbh_t*)(DBIc_PARENT_COM(imp_sth))]

Tim

p.s. Questions like this would be better directed to dbi-dev.

Reply via email to