0001-Only-list-tables-with-the-configured-table_prefix.patch
| system/libraries/drivers/Database/Mssql.php | ||
|---|---|---|
| 259 | 259 | |
| 260 | 260 |
public function list_tables() |
| 261 | 261 |
{
|
| 262 |
// FIXME does this even work? use information_schema.tables instead |
|
| 262 | 263 |
$sql = 'SHOW TABLES FROM ['.$this->db_config['connection']['database'].']'; |
| 263 | 264 |
$result = $this->query($sql)->result(FALSE, MSSQL_ASSOC); |
| 264 | 265 | |
| system/libraries/drivers/Database/Mysql.php | ||
|---|---|---|
| 275 | 275 |
{
|
| 276 | 276 |
$tables = array(); |
| 277 | 277 | |
| 278 |
if ($query = $this->query('SHOW TABLES FROM '.$this->escape_table($this->db_config['connection']['database'])))
|
|
| 278 |
$sql = 'SHOW TABLES FROM '. $this->escape_table($this->db_config['connection']['database']); |
|
| 279 | ||
| 280 |
if ($this->db_config['table_prefix']) |
|
| 281 |
{
|
|
| 282 |
$sql .= ' LIKE \''. $this->escape_str($this->db_config['table_prefix']) .'%\''; |
|
| 283 |
} |
|
| 284 | ||
| 285 |
if ($query = $this->query($sql)) |
|
| 279 | 286 |
{
|
| 280 | 287 |
foreach ($query->result(FALSE) as $row) |
| 281 | 288 |
{
|
| system/libraries/drivers/Database/Pdosqlite.php | ||
|---|---|---|
| 213 | 213 | |
| 214 | 214 |
public function list_tables() |
| 215 | 215 |
{
|
| 216 |
$sql = "SELECT `name` FROM `sqlite_master` WHERE `type`='table' ORDER BY `name`;"; |
|
| 216 |
$sql = "SELECT `name` FROM `sqlite_master` WHERE `type`='table'"; |
|
| 217 | ||
| 218 |
if ($this->db_config['table_prefix']) |
|
| 219 |
{
|
|
| 220 |
$sql .= " AND `name` LIKE '". $this->escape_str($this->db_config['table_prefix']) ."%';"; |
|
| 221 |
} |
|
| 222 | ||
| 217 | 223 |
try |
| 218 | 224 |
{
|
| 219 | 225 |
$result = $this->query($sql)->result(FALSE, PDO::FETCH_ASSOC); |
| system/libraries/drivers/Database/Pgsql.php | ||
|---|---|---|
| 238 | 238 | |
| 239 | 239 |
public function list_tables() |
| 240 | 240 |
{
|
| 241 |
$sql = 'SELECT table_schema || \'.\' || table_name FROM information_schema.tables WHERE table_schema NOT IN (\'pg_catalog\', \'information_schema\')'; |
|
| 242 |
$result = $this->query($sql)->result(FALSE, PGSQL_ASSOC); |
|
| 241 |
$tables = array(); |
|
| 243 | 242 | |
| 244 |
$retval = array(); |
|
| 245 |
foreach ($result as $row) |
|
| 243 |
$sql = 'SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema = \'public\''; |
|
| 244 | ||
| 245 |
if ($this->db_config['table_prefix']) |
|
| 246 |
{
|
|
| 247 |
$sql .= ' AND table_name LIKE \''. $this->escape_str($this->db_config['table_prefix']) .'%\''; |
|
| 248 |
} |
|
| 249 | ||
| 250 |
if ($result = $this->query($sql)) |
|
| 246 | 251 |
{
|
| 247 |
$retval[] = current($row); |
|
| 252 |
foreach ($result as $row) |
|
| 253 |
{
|
|
| 254 |
$tables[] = $row->table_name; |
|
| 255 |
} |
|
| 248 | 256 |
} |
| 249 | 257 | |
| 250 |
return $retval;
|
|
| 258 |
return $tables;
|
|
| 251 | 259 |
} |
| 252 | 260 | |
| 253 | 261 |
public function show_error() |