mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
685054fac3
commit
bd67cfc0db
1 changed files with 17 additions and 8 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue