mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +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
|
* @access public
|
||||||
*/
|
*/
|
||||||
function isInterfaceSupported($interface) {
|
function isInterfaceSupported($interface) {
|
||||||
$methods = get_class_methods(get_class($this));
|
static $methods = false;
|
||||||
$methods = strtolower(implode('|', $methods));
|
if ($methods === false) {
|
||||||
$methods = explode('|', $methods);
|
$methods = array_map('strtolower', get_class_methods($this));
|
||||||
$return = in_array(strtolower($interface), $methods);
|
}
|
||||||
return $return;
|
return in_array(strtolower($interface), $methods);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -605,7 +605,7 @@ class DboMysql extends DboMysqlBase {
|
||||||
} else {
|
} else {
|
||||||
$tables = array();
|
$tables = array();
|
||||||
|
|
||||||
while ($line = mysql_fetch_array($result)) {
|
while ($line = mysql_fetch_row($result)) {
|
||||||
$tables[] = $line[0];
|
$tables[] = $line[0];
|
||||||
}
|
}
|
||||||
parent::listSources($tables);
|
parent::listSources($tables);
|
||||||
|
@ -727,7 +727,6 @@ class DboMysql extends DboMysqlBase {
|
||||||
$j = 0;
|
$j = 0;
|
||||||
|
|
||||||
while ($j < $numFields) {
|
while ($j < $numFields) {
|
||||||
|
|
||||||
$column = mysql_fetch_field($results,$j);
|
$column = mysql_fetch_field($results,$j);
|
||||||
if (!empty($column->table)) {
|
if (!empty($column->table)) {
|
||||||
$this->map[$index++] = array($column->table, $column->name);
|
$this->map[$index++] = array($column->table, $column->name);
|
||||||
|
|
|
@ -140,7 +140,7 @@ class DboMysqli extends DboMysqlBase {
|
||||||
*/
|
*/
|
||||||
function listSources() {
|
function listSources() {
|
||||||
$cache = parent::listSources();
|
$cache = parent::listSources();
|
||||||
if ($cache != null) {
|
if ($cache !== null) {
|
||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
$result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database']) . ';');
|
$result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database']) . ';');
|
||||||
|
@ -151,7 +151,7 @@ class DboMysqli extends DboMysqlBase {
|
||||||
|
|
||||||
$tables = array();
|
$tables = array();
|
||||||
|
|
||||||
while ($line = mysqli_fetch_array($result)) {
|
while ($line = mysqli_fetch_row($result)) {
|
||||||
$tables[] = $line[0];
|
$tables[] = $line[0];
|
||||||
}
|
}
|
||||||
parent::listSources($tables);
|
parent::listSources($tables);
|
||||||
|
@ -290,14 +290,12 @@ class DboMysqli extends DboMysqlBase {
|
||||||
function fetchResult() {
|
function fetchResult() {
|
||||||
if ($row = mysqli_fetch_row($this->results)) {
|
if ($row = mysqli_fetch_row($this->results)) {
|
||||||
$resultRow = array();
|
$resultRow = array();
|
||||||
$i = 0;
|
|
||||||
foreach ($row as $index => $field) {
|
foreach ($row as $index => $field) {
|
||||||
$table = $column = null;
|
$table = $column = null;
|
||||||
if (count($this->map[$index]) == 2) {
|
if (count($this->map[$index]) === 2) {
|
||||||
list($table, $column) = $this->map[$index];
|
list($table, $column) = $this->map[$index];
|
||||||
}
|
}
|
||||||
$resultRow[$table][$column] = $row[$index];
|
$resultRow[$table][$column] = $row[$index];
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
return $resultRow;
|
return $resultRow;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue