mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
updated msqli driver
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3276 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
37e7d798d1
commit
6b62ff231a
1 changed files with 48 additions and 30 deletions
|
@ -104,6 +104,7 @@ class DboMysqli extends DboSource {
|
|||
if (mysqli_select_db($this->connection, $config['database'])) {
|
||||
$this->connected = true;
|
||||
}
|
||||
|
||||
return $this->connected;
|
||||
}
|
||||
/**
|
||||
|
@ -136,7 +137,6 @@ class DboMysqli extends DboSource {
|
|||
return $cache;
|
||||
}
|
||||
$result = $this->_execute('SHOW TABLES FROM ' . $this->config['database'] . ';');
|
||||
|
||||
if (!$result) {
|
||||
return array();
|
||||
} else {
|
||||
|
@ -164,7 +164,7 @@ class DboMysqli extends DboSource {
|
|||
}
|
||||
|
||||
$fields = false;
|
||||
$cols = $this->_execute('DESCRIBE ' . $this->fullTableName($model));
|
||||
$cols = $this->query('DESCRIBE ' . $this->fullTableName($model));
|
||||
|
||||
foreach ($cols as $column) {
|
||||
$colKey = array_keys($column);
|
||||
|
@ -172,7 +172,12 @@ class DboMysqli extends DboSource {
|
|||
$column[0] = $column[$colKey[0]];
|
||||
}
|
||||
if (isset($column[0])) {
|
||||
$fields[] = array('name' => $column[0]['Field'], 'type' => $this->column($column[0]['Type']), 'null' => $column[0]['Null']);
|
||||
$fields[] = array(
|
||||
'name' => $column[0]['Field'],
|
||||
'type' => $this->column($column[0]['Type']),
|
||||
'null' => $column[0]['Null'],
|
||||
'default' => $column[0]['Default']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,7 +312,7 @@ class DboMysqli extends DboSource {
|
|||
* @return int Number of rows in resultset
|
||||
*/
|
||||
function lastNumRows() {
|
||||
if ($this->_result and is_resource($this->_result)) {
|
||||
if ($this->_result and is_object($this->_result)) {
|
||||
return @mysqli_num_rows($this->_result);
|
||||
}
|
||||
return null;
|
||||
|
@ -389,10 +394,8 @@ class DboMysqli extends DboSource {
|
|||
$num_fields = mysqli_num_fields($results);
|
||||
$index = 0;
|
||||
$j = 0;
|
||||
|
||||
while ($j < $num_fields) {
|
||||
|
||||
$column = mysqli_fetch_field($results,$j);
|
||||
$column = mysqli_fetch_field_direct($results, $j);
|
||||
if (!empty($column->table)) {
|
||||
$this->map[$index++] = array($column->table, $column->name);
|
||||
} else {
|
||||
|
@ -411,7 +414,7 @@ class DboMysqli extends DboSource {
|
|||
$resultRow = array();
|
||||
$i = 0;
|
||||
foreach ($row as $index => $field) {
|
||||
list($table, $column) = $this->map[$index];
|
||||
@list($table, $column) = $this->map[$index];
|
||||
$resultRow[$table][$column] = $row[$index];
|
||||
$i++;
|
||||
}
|
||||
|
@ -420,6 +423,21 @@ class DboMysqli extends DboSource {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a row from given resultset as an array .
|
||||
*
|
||||
* @param bool $assoc Associative array only, or both?
|
||||
* @return array The fetched row as an array
|
||||
*/
|
||||
function fetchRow($assoc = false) {
|
||||
if (is_object($this->_result)) {
|
||||
$this->resultSet($this->_result);
|
||||
$resultRow = $this->fetchResult();
|
||||
return $resultRow;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue