Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: last_insert_id did not work

by bizactuator (Sexton)
on Mar 27, 2021 at 08:35 UTC ( [id://11130438]=note: print w/replies, xml ) Need Help??


in reply to last_insert_id did not work

I am so dumb. OMG. I just realized, I used a code for reading a database table... lol. $sth->fetchrow_hashref(); DUH, my bad. I cannot believe I messed up that so bad. errrgh. How do I use a statement like that to do it that way?
$sth = $dbh->prepare(qq{INSERT INTO `coacttran` SET $_pstmt"}); $sth->execute(@_placeholders); $sth->fetchrow_hashref(); $sth->finish(); $_chinsert = $sth->{mysql_insertid};
how do I make that work?
My bad. I'm totally exhausted, been working for 20 hours today. errgh. Should have slept first. lol. Sorry.

Replies are listed 'Best First'.
Re^2: last_insert_id did not work
by haukex (Archbishop) on Mar 27, 2021 at 08:42 UTC
    Should have slept first. lol. Sorry.

    No worries, it happens :-) Update: We missed it too!

Re^2: last_insert_id did not work
by mr_ron (Chaplain) on Mar 27, 2021 at 12:37 UTC
    I am trying this right now: $sth->{mysql_insertid};
    then later message:
    I just realized, I used a code for reading a database table... lol. $sth->fetchrow_hashref();
    From DBI docs ... last_insert_id of DBI
    * For some drivers the value may only available immediately after the insert statement has executed (e.g., mysql, Informix).

    Ron

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11130438]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-25 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found