Skip to content

Commit

Permalink
fix: "Undefined offset: 0" for backtick delimiters and address relate…
Browse files Browse the repository at this point in the history
…d issues (#995, #967, #928)

This commit fixes the "Undefined offset: 0" error that occurred in the rawAddPrefix function when using backtick delimiters for table names in SQL queries. It also addresses issues reported in tickets #995, #967, and #928, which were likely related to the same underlying problem with table name identification.

Changes:

Updated the regular expression in rawAddPrefix to match backtick characters (\) as valid delimiters for table names.

This fix ensures that the function correctly identifies and prefixes table names regardless of the delimiter used.
  • Loading branch information
ThingEngineer authored May 24, 2024
1 parent c740505 commit 469666d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion MysqliDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ private function queryUnprepared($query)
public function rawAddPrefix($query){
$query = str_replace(PHP_EOL, '', $query);
$query = preg_replace('/\s+/', ' ', $query);
preg_match_all("/(from|into|update|join|describe) [\\'\\´]?([a-zA-Z0-9_-]+)[\\'\\´]?/i", $query, $matches);
preg_match_all("/(from|into|update|join|describe) [\\'\\´\\`]?([a-zA-Z0-9_-]+)[\\'\\´\\`]?/i", $query, $matches);
list($from_table, $from, $table) = $matches;

// Check if there are matches
Expand Down

0 comments on commit 469666d

Please sign in to comment.