Re: adding key to DB object

From: David Goodman (dtzgdman_at_yahoo.com)
Date: 03/29/05


Date: Tue, 29 Mar 2005 12:33:03 -0800 (PST)
To: dbi-users@perl.org

Hello Brandon:

Why do you see using private attributes like
$dbh->{private_commitflag} as preferable to embedding
a dbh in your own object?

regards,

David

--- Tim Bunce <Tim.Bunce@pobox.com> wrote:
> On Tue, Mar 29, 2005 at 12:20:09PM -0600, Brandon
> Metcalf wrote:
> > j == jeff@vpservices.com writes:
> >
> > j> No, that's wrong. It may look like a hash,
> but when you set or query
> > j> attributes, you are actually calling the
> STORE() and FETCH() methods of
> > j> the DBD and of DBI. You can only set
> attributes that can be handled by
> > j> the DBD and by DBI, you can't invent new
> attributes.
>
> Unless they start with "private_".
>
> If you enable trace you'll see a message like
>
> $h->{commitflag}=1 ignored for invalid
> driver-specific attribute
>
> > Ah, got it. Basically, what I'm trying to do is
> track whether I've
> > encountered any errors during a transaction within
> the object itself,
> > so I can do something like:
> >
> > eval { $dbh->execute; };
> > $dbh->{commitflag} = 0 if $@;
> >
> > Is there some existing attribute that will do what
> I need?
>
> $dbh->{private_commitflag} would work.
>
> Tim.
>



Relevant Pages