SQLite: Support ` in PRIMARY KEY
This commit is contained in:
parent
964a988fef
commit
718f9d3791
|
@ -337,9 +337,9 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
$return = array();
|
$return = array();
|
||||||
$sql = $connection2->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table));
|
$sql = $connection2->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table));
|
||||||
if (preg_match('~\bPRIMARY\s+KEY\s*\((([^)"]+|"[^"]*")++)~i', $sql, $match)) {
|
if (preg_match('~\bPRIMARY\s+KEY\s*\((([^)"]+|"[^"]*"|`[^`]*`)++)~i', $sql, $match)) {
|
||||||
$return[""] = array("type" => "PRIMARY", "columns" => array(), "lengths" => array(), "descs" => array());
|
$return[""] = array("type" => "PRIMARY", "columns" => array(), "lengths" => array(), "descs" => array());
|
||||||
preg_match_all('~((("[^"]*+")+)|(\S+))(\s+(ASC|DESC))?(,\s*|$)~i', $match[1], $matches, PREG_SET_ORDER);
|
preg_match_all('~((("[^"]*+")+|(?:`[^`]*+`)+)|(\S+))(\s+(ASC|DESC))?(,\s*|$)~i', $match[1], $matches, PREG_SET_ORDER);
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
$return[""]["columns"][] = idf_unescape($match[2]) . $match[4];
|
$return[""]["columns"][] = idf_unescape($match[2]) . $match[4];
|
||||||
$return[""]["descs"][] = (preg_match('~DESC~i', $match[5]) ? '1' : null);
|
$return[""]["descs"][] = (preg_match('~DESC~i', $match[5]) ? '1' : null);
|
||||||
|
|
Loading…
Reference in a new issue