public function list_tables($constrain_by_prefix = FALSE)
{
// Is there a cached result?
if (isset($this->data_cache['table_names'])) {
return $this->data_cache['table_names'];
}
if (FALSE === ($sql = $this->_list_tables($constrain_by_prefix))) {
return $this->db_debug ? $this->display_error('db_unsupported_function') : FALSE;
}
$this->data_cache['table_names'] = array();
$query = $this->query($sql);
foreach ($query->result_array() as $row) {
// Do we know from which column to get the table name?
if (!isset($key)) {
if (isset($row['table_name'])) {
$key = 'table_name';
} elseif (isset($row['TABLE_NAME'])) {
$key = 'TABLE_NAME';
} else {
/* We have no other choice but to just get the first element's key.
* Due to array_shift() accepting its argument by reference, if
* E_STRICT is on, this would trigger a warning. So we'll have to
* assign it first.
*/
$key = array_keys($row);
$key = array_shift($key);
}
}
$this->data_cache['table_names'][] = $row[$key];
}
return $this->data_cache['table_names'];
}