Adding fallback for deprecated function mysql_list_tables() in DboMysql::listSources()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4323 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-01-23 22:23:39 +00:00
parent 685054fac3
commit bd67cfc0db

View file

@ -142,20 +142,29 @@ class DboMysql extends DboSource {
if ($cache != null) {
return $cache;
}
$tables = array();
$result = mysql_list_tables($this->config['database'], $this->connection);
if (!$result) {
return array();
} else {
$tables = array();
if ($result) {
while ($line = mysql_fetch_array($result)) {
$tables[] = $line[0];
}
parent::listSources($tables);
return $tables;
}
if (empty($tables)) {
$result = $this->query('SHOW TABLES');
$key1 = $key2 = null;
foreach ($result as $item) {
if (empty($key1)) {
$key1 = key($item);
$key2 = key($item[$key1]);
}
$tables[] = $item[$key1][$key2];
}
}
parent::listSources($tables);
return $tables;
}
/**
* Returns an array of the fields in given table name.