I had a search through the forum for my problem and have checked all the obvious stuff. We recently changed one of our apps from MySQLi to MySQL. We were using mysqli_insert_id to return the last inserted id, but due to the change we moved everything about and the new code only returns 0.
Code: Select all
public function addBlankItem()
{
$sql = "INSERT INTO paxProfile () VALUES ()";
$this->connection->directExecute( $sql );
$this->lastID = $this->connection->getLastID();
}
public function getLastID()
{
$sql = "SELECT LAST_INSERT_ID() AS id";
$RS = mysql_query($sql, $this->dataConnection);
$row = mysql_fetch_assoc($RS);
return $row;
}
The tables key field contains an auto increment number, so that part is ok, and no other queries are run after the INSERT so that should be ok. Does any one have any idea why I keep getting 0 returned??
Thanks All!