Permalink
Browse files

Minor optimization on datasource and Mysql[i].

  • Loading branch information...
1 parent e328043 commit c4afeb3fe6965439047b5a9fb35699fabdb1a507 @jrbasso jrbasso committed with lorenzo Jan 19, 2010
@@ -436,11 +436,11 @@ function enabled() {
* @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 @@ function listSources() {
} 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 @@ function resultSet(&$results) {
$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 @@ function _executeProcedure($sql) {
*/
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 @@ function listSources() {
$tables = array();
- while ($line = mysqli_fetch_array($result)) {
+ while ($line = mysqli_fetch_row($result)) {
$tables[] = $line[0];
}
parent::listSources($tables);
@@ -290,14 +290,12 @@ function resultSet(&$results) {
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;
}

0 comments on commit c4afeb3

Please sign in to comment.