Thanks for all of the help. I appologize because I should have actually said $dbh->{'mysql_insertid'}, sorry for the confusion.
What I ended up doing is writting a quick function to look at the table and return
the first auto_increment field it found.
This is what I came up with:
sub get_auto_increment {
my ($dbh, $table) = @_;
my $sth = $dbh->prepare("show columns from $table");
$sth->execute;
my $ref;
while ($ref = $sth->fetchrow_hashref) {
if ($ref->{'Extra'} eq 'auto_increment') {
$sth->finish;
return $ref->{'Field'};
}
}
$sth->finish;
return undef;
}
The idea is that the first column that matches 'auto_increment'
will be the column that $dbh->{'mysql_insertid'} is referring to.
I am not sure what the rules are for mysql's auto_increment definition.
If I am not mistaken (which I probably am) all columns marked
auto_increment would get the same value anyway?
Thanks,
-Art-
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.