Adding fix for Ticket #2363

Removed use of:
mysql_insert_id($this->connection);
mysqli_insert_id($this->connection);

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4810 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-04-07 01:42:12 +00:00
parent 8b2e2e6a7a
commit 784ee985b5
2 changed files with 9 additions and 16 deletions

View file

@ -330,15 +330,11 @@ class DboMysql extends DboSource {
* @return in * @return in
*/ */
function lastInsertId($source = null) { function lastInsertId($source = null) {
$id = mysql_insert_id($this->connection); $id = $this->fetchAll('SELECT LAST_INSERT_ID() AS insertID', false);
if ($id) { if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0][0]['insertID'])) {
return $id; return $id[0][0]['insertID'];
} }
$data = $this->fetchAll('SELECT LAST_INSERT_ID() as id From '.$source);
if ($data && isset($data[0]['id'])) {
return $data[0]['id'];
}
return null; return null;
} }
/** /**
@ -569,4 +565,4 @@ class DboMysql extends DboSource {
return $query; return $query;
} }
} }
?> ?>

View file

@ -322,15 +322,12 @@ class DboMysqli extends DboSource {
* @return in * @return in
*/ */
function lastInsertId($source = null) { function lastInsertId($source = null) {
$id = mysqli_insert_id($this->connection); $id = $this->fetchAll('SELECT LAST_INSERT_ID() AS insertID', false);
if ($id) { if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0][0]['insertID'])) {
return $id; return $id[0][0]['insertID'];
}
$data = $this->fetchAll('SELECT LAST_INSERT_ID() as id From '.$source);
if ($data && isset($data[0]['id'])) {
return $data[0]['id'];
} }
return null;
} }
/** /**
* Converts database-layer column types to basic types * Converts database-layer column types to basic types