mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding enhancement suggestion from #1565 to all Dbo classes
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5166 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
4e92b97468
commit
232b109bef
5 changed files with 21 additions and 21 deletions
|
@ -129,11 +129,11 @@ class DboDb2 extends DboSource {
|
|||
if ($this->connection) {
|
||||
$this->connected = true;
|
||||
}
|
||||
|
||||
|
||||
if ($config['schema'] !== '') {
|
||||
$this->_execute('SET CURRENT SCHEMA = ' . $config['schema']);
|
||||
}
|
||||
|
||||
$this->_execute('SET CURRENT SCHEMA = ' . $config['schema']);
|
||||
}
|
||||
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
|
@ -158,13 +158,13 @@ class DboDb2 extends DboSource {
|
|||
function _execute($sql) {
|
||||
// get result from db
|
||||
$result = db2_exec($this->connection, $sql);
|
||||
|
||||
|
||||
// build table/column map for this result
|
||||
$map = array();
|
||||
$num_fields = db2_num_fields($result);
|
||||
$index = 0;
|
||||
$j = 0;
|
||||
|
||||
|
||||
while ($j < $num_fields) {
|
||||
$columnName = strtolower(db2_field_name($result, $j));
|
||||
$tableName = substr($sql, 0, strpos($sql, '.' . $columnName));
|
||||
|
@ -172,9 +172,9 @@ class DboDb2 extends DboSource {
|
|||
$map[$index++] = array($tableName, $columnName);
|
||||
$j++;
|
||||
}
|
||||
|
||||
|
||||
$this->_resultMap[$result] = $map;
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
|
@ -413,7 +413,7 @@ class DboDb2 extends DboSource {
|
|||
* @return in
|
||||
*/
|
||||
function lastInsertId($source = null) {
|
||||
$data = $this->fetchAll(sprintf('SELECT SYSIBM.IDENTITY_VAL_LOCAL() AS ID FROM %s FETCH FIRST ROW ONLY', $source));
|
||||
$data = $this->fetchRow(sprintf('SELECT SYSIBM.IDENTITY_VAL_LOCAL() AS ID FROM %s FETCH FIRST ROW ONLY', $source));
|
||||
|
||||
if ($data && isset($data[0]['id'])) {
|
||||
return $data[0]['id'];
|
||||
|
|
|
@ -391,8 +391,8 @@ class DboMssql extends DboSource {
|
|||
* @return in
|
||||
*/
|
||||
function lastInsertId($source = null) {
|
||||
$id = $this->fetchAll('SELECT SCOPE_IDENTITY() AS insertID', false);
|
||||
return $id[0][0]['insertID'];
|
||||
$id = $this->fetchRow('SELECT SCOPE_IDENTITY() AS insertID', false);
|
||||
return $id[0]['insertID'];
|
||||
}
|
||||
/**
|
||||
* Returns a limit statement in the correct format for the particular database.
|
||||
|
@ -484,7 +484,7 @@ class DboMssql extends DboSource {
|
|||
} elseif(isset($this->__fieldMappings[$column])) {
|
||||
$map = array(0, $this->__fieldMappings[$column]);
|
||||
} else {
|
||||
$map = array(0, $column);
|
||||
$map = array(0, $column);
|
||||
}
|
||||
$this->map[$index++] = $map;
|
||||
} else {
|
||||
|
@ -494,7 +494,7 @@ class DboMssql extends DboSource {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Builds final SQL statement
|
||||
* Builds final SQL statement
|
||||
*
|
||||
* @param array $data Query data
|
||||
* @return string
|
||||
|
@ -513,7 +513,7 @@ class DboMssql extends DboSource {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Reverses the sort direction of ORDER statements to get paging offsets to work correctly
|
||||
* Reverses the sort direction of ORDER statements to get paging offsets to work correctly
|
||||
*
|
||||
* @param string $order
|
||||
* @return string
|
||||
|
|
|
@ -318,9 +318,9 @@ class DboMysql extends DboSource {
|
|||
* @return in
|
||||
*/
|
||||
function lastInsertId($source = null) {
|
||||
$id = $this->fetchAll('SELECT LAST_INSERT_ID() AS insertID', false);
|
||||
if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0][0]['insertID'])) {
|
||||
return $id[0][0]['insertID'];
|
||||
$id = $this->fetchRow('SELECT LAST_INSERT_ID() AS insertID', false);
|
||||
if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) {
|
||||
return $id[0]['insertID'];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -307,9 +307,9 @@ class DboMysqli extends DboSource {
|
|||
* @return in
|
||||
*/
|
||||
function lastInsertId($source = null) {
|
||||
$id = $this->fetchAll('SELECT LAST_INSERT_ID() AS insertID', false);
|
||||
if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0][0]['insertID'])) {
|
||||
return $id[0][0]['insertID'];
|
||||
$id = $this->fetchRow('SELECT LAST_INSERT_ID() AS insertID', false);
|
||||
if ($id !== false && !empty($id) && !empty($id[0]) && isset($id[0]['insertID'])) {
|
||||
return $id[0]['insertID'];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -367,7 +367,7 @@ class DboOdbc extends DboSource{
|
|||
* @return int
|
||||
*/
|
||||
function lastInsertId($source = null) {
|
||||
$result=$this->fetchAll('SELECT @@IDENTITY');
|
||||
$result=$this->fetchRow('SELECT @@IDENTITY');
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue