mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
toMySQL() added keyname to index if available
getIndex() now supports also the INDEX keyword
This commit is contained in:
parent
eeaa9b22a8
commit
e1920c740a
@ -641,7 +641,10 @@ class db_verify
|
||||
// print_a($data);
|
||||
if($data['type'])
|
||||
{
|
||||
return $data['type']." (".$data['field'].");";
|
||||
//return $data['type']." (".$data['field'].");";
|
||||
// Check if index keyname exists and add backticks
|
||||
$keyname = (!empty($data['keyname']) ? " `".$data['keyname']."`" : "");
|
||||
return $data['type'] . $keyname . " (" . $data['field'] . ");";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -919,9 +922,15 @@ class db_verify
|
||||
function getIndex($data, $print = false)
|
||||
{
|
||||
// $regex = "/(?:(PRIMARY|UNIQUE|FULLTEXT))?[\s]*?KEY (?: ?`?([\w]*)`?)[\s]* ?(?:\([\s]?`?([\w,]*[\s]?)`?\))?,?/i";
|
||||
$regex = "/(?:(PRIMARY|UNIQUE|FULLTEXT|FOREIGN))?[\s]*?KEY (?: ?`?([\w]*)`?)[\s]* ?(?:\([\s]?([\w\s,`]*[\s]?)`?\))?,?/i";
|
||||
// $regex = "/(?:(PRIMARY|UNIQUE|FULLTEXT|FOREIGN))?[\s]*?KEY (?: ?`?([\w]*)`?)[\s]* ?(?:\([\s]?([\w\s,`]*[\s]?)`?\))?,?/i";
|
||||
$regex = "/(?:(PRIMARY|UNIQUE|FULLTEXT|FOREIGN))?[\s]*?(INDEX|KEY) (?: ?`?([\w]*)`?)[\s]* ?(?:\([\s]?([\w\s,`]*[\s]?)`?\))?,?/i";
|
||||
preg_match_all($regex,$data,$m);
|
||||
|
||||
|
||||
if (count($m) > 0)
|
||||
{
|
||||
unset($m[2]);
|
||||
$m = array_combine(range(0, count($m)-1), array_values($m));
|
||||
}
|
||||
$ret = array();
|
||||
|
||||
if($print)
|
||||
@ -933,6 +942,7 @@ class db_verify
|
||||
|
||||
$fieldReplace = array("`"," ");
|
||||
|
||||
|
||||
foreach($m[3] as $k=>$val)
|
||||
{
|
||||
if(!$val) continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user