mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding recent fixes to DboDb2 driver
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5613 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
92f9c81dfb
commit
b574a98306
1 changed files with 21 additions and 17 deletions
|
@ -28,7 +28,6 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* IBM DB2 for DBO
|
||||
*
|
||||
|
@ -158,23 +157,28 @@ 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));
|
||||
$tableName = substr($tableName, strrpos($tableName, ' ') + 1);
|
||||
$map[$index++] = array($tableName, $columnName);
|
||||
$j++;
|
||||
|
||||
if(!is_bool($result)){
|
||||
// build table/column map for this result
|
||||
$map = array();
|
||||
$num_fields = db2_num_fields($result);
|
||||
$index = 0;
|
||||
$j = 0;
|
||||
$offset = 0;
|
||||
|
||||
while ($j < $num_fields) {
|
||||
$columnName = strtolower(db2_field_name($result, $j));
|
||||
$tmp = strpos($sql, '.' . $columnName, $offset);
|
||||
$tableName = substr($sql, $offset, ($tmp-$offset));
|
||||
$tableName = substr($tableName, strrpos($tableName, ' ') + 1);
|
||||
$map[$index++] = array($tableName, $columnName);
|
||||
$j++;
|
||||
$offset = strpos($sql, ' ', $tmp);
|
||||
}
|
||||
|
||||
$this->_resultMap[$result] = $map;
|
||||
}
|
||||
|
||||
$this->_resultMap[$result] = $map;
|
||||
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
|
@ -217,7 +221,7 @@ class DboDb2 extends DboSource {
|
|||
|
||||
while (db2_fetch_row($result)) {
|
||||
$fields[strtolower(db2_result($result, 'COLUMN_NAME'))] = array(
|
||||
'type' => db2_result($result, 'TYPE_NAME'),
|
||||
'type' => strtolower(db2_result($result, 'TYPE_NAME')),
|
||||
'null' => db2_result($result, 'NULLABLE'),
|
||||
'default' => db2_result($result, 'COLUMN_DEF'));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue