mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Minor optimization on datasource and Mysql[i].
This commit is contained in:
parent
e328043586
commit
c4afeb3fe6
3 changed files with 9 additions and 12 deletions
|
@ -436,11 +436,11 @@ class DataSource extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function isInterfaceSupported($interface) {
|
||||
$methods = get_class_methods(get_class($this));
|
||||
$methods = strtolower(implode('|', $methods));
|
||||
$methods = explode('|', $methods);
|
||||
$return = in_array(strtolower($interface), $methods);
|
||||
return $return;
|
||||
static $methods = false;
|
||||
if ($methods === false) {
|
||||
$methods = array_map('strtolower', get_class_methods($this));
|
||||
}
|
||||
return in_array(strtolower($interface), $methods);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -605,7 +605,7 @@ class DboMysql extends DboMysqlBase {
|
|||
} else {
|
||||
$tables = array();
|
||||
|
||||
while ($line = mysql_fetch_array($result)) {
|
||||
while ($line = mysql_fetch_row($result)) {
|
||||
$tables[] = $line[0];
|
||||
}
|
||||
parent::listSources($tables);
|
||||
|
@ -727,7 +727,6 @@ class DboMysql extends DboMysqlBase {
|
|||
$j = 0;
|
||||
|
||||
while ($j < $numFields) {
|
||||
|
||||
$column = mysql_fetch_field($results,$j);
|
||||
if (!empty($column->table)) {
|
||||
$this->map[$index++] = array($column->table, $column->name);
|
||||
|
|
|
@ -140,7 +140,7 @@ class DboMysqli extends DboMysqlBase {
|
|||
*/
|
||||
function listSources() {
|
||||
$cache = parent::listSources();
|
||||
if ($cache != null) {
|
||||
if ($cache !== null) {
|
||||
return $cache;
|
||||
}
|
||||
$result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database']) . ';');
|
||||
|
@ -151,7 +151,7 @@ class DboMysqli extends DboMysqlBase {
|
|||
|
||||
$tables = array();
|
||||
|
||||
while ($line = mysqli_fetch_array($result)) {
|
||||
while ($line = mysqli_fetch_row($result)) {
|
||||
$tables[] = $line[0];
|
||||
}
|
||||
parent::listSources($tables);
|
||||
|
@ -290,14 +290,12 @@ class DboMysqli extends DboMysqlBase {
|
|||
function fetchResult() {
|
||||
if ($row = mysqli_fetch_row($this->results)) {
|
||||
$resultRow = array();
|
||||
$i = 0;
|
||||
foreach ($row as $index => $field) {
|
||||
$table = $column = null;
|
||||
if (count($this->map[$index]) == 2) {
|
||||
if (count($this->map[$index]) === 2) {
|
||||
list($table, $column) = $this->map[$index];
|
||||
}
|
||||
$resultRow[$table][$column] = $row[$index];
|
||||
$i++;
|
||||
}
|
||||
return $resultRow;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue