All,
I have some PHP PDO code that looks like this:
<?php
...
$query=$dbh->prepare("SELECT LAST_INSERT_ID()");
$query->execute();
$result=$query->fetch(PDO::FETCH_ASSOC); // returns an array indexed by column name as returned in result set - here column name is "userID" in the DB
print_r($result);
...
When I run this, the result of print_r($result);
is something like Array([LAST_INSERT_ID()]=>18)
. Why is the array indexed on [LAST_INSERT_ID()]
as opposed to userID
, which is the name of my column in the data table? The PHP manual says:
PDO::FETCH_ASSOC: returns an array indexed by column name as returned in your result set
What am I missing?
Thanks,
JDelage