Re: [Sqlrelay-discussion] mysql_insertid
Brought to you by:
mused
|
From: Ady W. <ady...@re...> - 2006-03-24 04:24:47
|
Hi Gaucho
Maybe you should run this query : "select last_insert_id()"
Good luck
Gaucho wrote:
> Hi there,
>
> I've searched all around and found hints from different posts but
> still can't find the answer to this problem....
>
> I just implemented sqlrelay with my mysql server (4.0.22) and I had
> some code that used to work that got the insertid from an
> autoincrement field when I inserted it as such:
>
> --------------------------------------
> $sql_query = " INSERT INTO mytable (autoinc_field,y,z) VALUES
> ('','foo','bar')";
> $db_ptr = &run_sqlquery($sql_query);
> my $insert_id = $db->{'mysql_insertid'};
> print STDERR "I GOT THIS: $insert_id\n";
>
> --------------------------------------
>
> When I run that code directly to the database, it prints out the value
> assigned to the autoincrement field in that table when I inserted...
> when I run it through sqlrelay it returns blank.
>
> Does this functionality not work in sqlrelay? Is there a workaround?
>
> Some supplimental info:
>
> I'm using the DBI::SQLRelay dropin functionality to replace the
> current way I'm doing it with DBI / DBD::mysql.
>
> The relevant part of the runsqlquery function is as follows:
>
> --------------------
> sub run_sqlquery{
> my ($sql_query) = @_;
>
> my $prepared = $db->prepare($sql_query);
> my $dbquery = $prepared->execute();
> return $prepared;
> }
>
> ---------------------------
>
>
>
> Any help would be greatly appreciated.
>
>
>
> //Gaucho
>
|