[CDBI] DBI's last_insert_id and Class::DBI's _auto_increment_value
carbon at pobox.com
Mon Nov 21 15:30:45 GMT 2005
Peter Speltz wrote:
> I thought you had to define a sequence in you CDBI code for PG cause
> it does not have auto inc columns. Is that right?
Ok, this makes sense. But does then tie your code to only working with
database that support sequences? My goal is to be able to have the same
codebase be able to work on top of both MySQL and Postgres (maybe even
SQLite at some point). It seems to me that using last_insert_id in the
_auto_increment_value method would not only clean up the code for that
method but make it so that you would not have to define a sequence and be
more database agnostic.
My system is currently working as I just described. I would have to test to
see if defining sequences in my CDBI objects breaks compatibility with MySQL
but regardless It seems to me that CDBI using last_insert_id on the backend
is a much more elegant solution.
More information about the ClassDBI