Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1913 Database export should ignore views #1973

Merged
merged 2 commits into from Jun 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions inc/db_mysql.php
Expand Up @@ -633,11 +633,18 @@ function list_tables($database, $prefix='')
{
if($prefix)
{
$query = $this->query("SHOW TABLES FROM `$database` LIKE '".$this->escape_string($prefix)."%'");
$query = $this->query("
SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES
WHERE `TABLE_SCHEMA` = '$database' AND `TABLE_TYPE` = 'BASE TABLE'
AND `TABLE_NAME` LIKE '".$this->escape_string($prefix)."%'
");
}
else
{
$query = $this->query("SHOW TABLES FROM `$database`");
$query = $this->query("
SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES
WHERE `TABLE_SCHEMA` = '$database' AND `TABLE_TYPE` = 'BASE TABLE'
");
}

$tables = array();
Expand All @@ -659,8 +666,9 @@ function table_exists($table)
{
// Execute on master server to ensure if we've just created a table that we get the correct result
$query = $this->write_query("
SHOW TABLES
LIKE '{$this->table_prefix}$table'
SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES
WHERE `TABLE_TYPE` = 'BASE TABLE'
AND `TABLE_NAME` LIKE '{$this->table_prefix}$table'
");
$exists = $this->num_rows($query);
if($exists > 0)
Expand Down
16 changes: 12 additions & 4 deletions inc/db_mysqli.php
Expand Up @@ -630,11 +630,18 @@ function list_tables($database, $prefix='')
{
if($prefix)
{
$query = $this->query("SHOW TABLES FROM `$database` LIKE '".$this->escape_string($prefix)."%'");
$query = $this->query("
SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES
WHERE `TABLE_SCHEMA` = '$database' AND `TABLE_TYPE` = 'BASE TABLE'
AND `TABLE_NAME` LIKE '".$this->escape_string($prefix)."%'
");
}
else
{
$query = $this->query("SHOW TABLES FROM `$database`");
$query = $this->query("
SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES
WHERE `TABLE_SCHEMA` = '$database' AND `TABLE_TYPE` = 'BASE TABLE'
");
}

$tables = array();
Expand All @@ -655,8 +662,9 @@ function table_exists($table)
{
// Execute on master server to ensure if we've just created a table that we get the correct result
$query = $this->write_query("
SHOW TABLES
LIKE '{$this->table_prefix}$table'
SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES
WHERE `TABLE_TYPE` = 'BASE TABLE'
AND `TABLE_NAME` LIKE '{$this->table_prefix}$table'
");
$exists = $this->num_rows($query);

Expand Down