-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
listTables() failing to use correct prefix #2210
Comments
Postrge seems to provide an additional
But I don't think that works in MySQLi and it's trying to use |
There are actually a couple problems here... The escape character is one, but I'm baffled why it isn't causing failures in #2211. The other issue is that |
From what I can see this is a bug inherited from CI3. The thing is that SHOW TABLES FROM `database` LIKE 'dev!_%' ESCAPE '!'; We can try to use something like this: SELECT `table_name` FROM information_schema.tables WHERE `table_schema` = 'database' AND `table_name` LIKE 'dev!_%' ESCAPE '!'; But I'm not sure if users always have access to protected function _listTables(bool $prefixLimit = false): string
{
$sql = 'SHOW TABLES FROM ' . $this->escapeIdentifiers($this->database);
if ($prefixLimit !== false && $this->DBPrefix !== '')
{
$sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '" . $this->escapeIdentifiers($this->database) . "' AND table_name LIKE '" . $this->escapeLikeString($this->DBPrefix) . "%'" . sprintf($this->likeEscapeStr, $this->likeEscapeChar);
}
return $sql;
} |
Ah that’s good info! I didn’t realize Incidentally I think |
Is this now fixed then, by #2229? |
Yes! Closing. |
Linux, PHP 7.2, Latest develop branch, MySQLi
If I use
$db->listTables(true)
(for$constrainByPrefix
) with a prefix that includes an_
I get a SQL statement that doesn't work. Pseudo-code:I see that it is trying to escape the underscore with a bang (!):
SHOW TABLES FROM
databaseLIKE 'dev!_%'
Tracing it back this is indeed what is set on the BaseConnection:
What am I missing? That doesn't work as an escape, should be
\
, right?The text was updated successfully, but these errors were encountered: