Re: Class::DBI _auto_increment_value update/suggestion

[prev] [thread] [next] [Date index for 2005/06/27]

From: Tim Bunce
Subject: Re: Class::DBI _auto_increment_value update/suggestion
Date: 09:02 on 27 Jun 2005
On Sun, Jun 26, 2005 at 10:35:51AM +0100, Tony Bowden wrote:
> On Thu, Jun 23, 2005 at 10:28:51PM +0100, Tim Bunce wrote:
> > > >    my $id  = $dbh->last_insert_id(undef, undef, $self->table, undef );
> > > Tim, does this sound like a good idea?
> > Yes, though "most DB drivers already handle it" may be a little optimistic.
> > It returns undef "if the driver does not support the method or can't
> > determine the value" so if you get an undef you're no worse off than before.
> 
> Well, we're worse off than before if we actually replace the code that
> does the specific calls to MySQL and SQLite with the generic version,
> and they break. 

Don't replace the code that does the specific calls, just preceede it
with a call to last_insert_id. If that returns undef then fall through
into the old code.

Tim.

> I can't make the specific DBD versions of MySQL and SQLite be pre-reqs, as
> they're not required at all. But it might be worth noting in the docs
> that people will need certain versions if they're using those databases
> and want to use auto-incrementing PKs?
> 
> Tony

Re: Class::DBI _auto_increment_value update/suggestion
Tim Bunce 09:02 on 27 Jun 2005

Generated at 16:35 on 28 Jul 2005 by mariachi v0.52