On Wed 02 Jan 2002 07:50, Chip Turner <[EMAIL PROTECTED]> wrote:
> Tim Bunce <[EMAIL PROTECTED]> writes:
> 
> > I'm pondering deprecating prepare_cached() in favor of requesting a
> > cached prepare() by passing the $statement as a reference to a string.
> > 
> > A big plus from this would be that $dbh->do(\$statement) would then
> > also be defined to do a prepare_cached().
> > 
> > Any comments?
> 
> The use of a string ref doesn't seem very intuitive; just an arbitrary
> way of overloading a function in a way that has no intuitive
> connotations to its function.  How about being able to change the
> policy of the $dbh, so that it defaults to cached or uncached ones?
> Or maybe something like this:
> 
>   $dbh->do("foo");             # uncached or cached, depends on default policy
>   $dbh->cached->do("foo");     # always cached
>   $dbh->uncached->do("foo");   # always uncached
> 
>   $dbh->policy('cached');      # set the policy, offers other options later
> 
>   $dbh->push_policy('cached'); # similar to the above, but use a 
>                                # policy stack similar to local
> 
>   local $dbh->{cached} = 1;    # or even this way, but this isn't as nice
> 
>   $dbh->default_cached;        # or this way
>   $dbh->default_uncached;      # ditto

Either this or Matthew's suggestion I'd go for.
Good thoughts both of you :)

Happy 2002

> Some of these could be done by making $dbh->cached() return a wrapper
> object that passes method calls to an internally stored reference to
> the real $dbh.  When that object goes out of scope (after the above
> method call), its DESTROY method could change back the policy for the
> $dbh.  Or, alternatively, the passthrough methods of this object would
> call cached versions of the appropriate methods (do_cached,
> prepare_cached, etc).  Either way isn't too hard (harder than just
> using a scalar ref, though) but offers a much more intuitive /
> communicative approach IMO.
> 
> I think something explicit is better than doing odd things with data
> structures/polymorphism, though.
> 
> Chip
> 
> -- 
> Chip Turner                   [EMAIL PROTECTED]
>                               Red Hat Network


-- 
H.Merijn Brand        Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using perl-5.6.1, 5.7.1 & 630 on HP-UX 10.20 & 11.00, AIX 4.2, AIX 4.3,
     WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.022 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/

Reply via email to