{$k} |
{$fname}
";
if (strpos($fparams, 'KEY') !== FALSE)
{
$head_txt .= " {$fparams} aa";
}
$head_txt .= " |
";
$xfieldnum = -1;
$body_txt = '';
foreach($lines as $l)
{
$xfieldnum++;
list($xl, $tmp) = explode("\n", $l, 2); // $tmp should be null
$xl = ltrim(rtrim(stripslashes($xl)));
$xl = preg_replace('/\r?\n$|\r[^\n]$/', '', $xl);
$xl = str_replace(' ',' ',$xl); // Remove double spaces
list($xfname, $xfparams) = explode(" ", $xl, 2); // Field name and the rest
if ($xfname == 'UNIQUE' || $xfname == 'FULLTEXT')
{
list($key, $key1, $keyname, $keyparms) = explode(" ", $xl, 4);
$xfname = $key." ".$key1." ".$keyname;
$xfparams = $keyparms;
}
elseif ($xfname == "KEY")
{
list($key, $keyname, $keyparms) = explode(" ", $xl, 3);
$xfname = $key." ".$keyname;
$xfparams = $keyparms;
}
if ($xfname != "CREATE" && $xfname != ")")
{
$xfields[$xfname] = 1;
}
$xfparams = preg_replace('/,$/', '', $xfparams);
$fparams = preg_replace('/,$/', '', $fparams);
if ($xfname == $fname)
{ // Field names match - or it could be the word 'KEY' and its name which matches
$ffound = 1;
//echo "Field: ".$xfname." Actuals: ".$xfparams." Expected: ".$fparams."
";
$xfsplit = explode(' ',$xfparams);
$fsplit = explode(' ',$fparams);
$skip = FALSE;
$i = 0;
$fld_err = FALSE;
foreach ($xfsplit as $xf)
{
if ($skip)
{
$skip = FALSE;
// echo " Unskip: ".$xf."
";
}
elseif (strcasecmp(trim($xf),'collate') == 0)
{ // Strip out the collation definition
$skip = TRUE;
// cho "Skip = ".$xf;
}
else
{
// echo "Compare: ".$xf." - ".$fsplit[$i]."
";
// Since VARCHAR and CHAR are interchangeable, convert to CHAR (strictly, VARCHAR(3) and smalller becomes CHAR() )
if (stripos($xf,'VARCHAR') === 0) $xf = substr($xf,3);
if (stripos($fsplit[$i],'VARCHAR') === 0) $fsplit[$i] = substr($fsplit[$i],3);
if (strcasecmp(trim($xf),trim($fsplit[$i])) != 0)
{
$fld_err = TRUE;
//echo "Mismatch: ".$xf." - ".$fsplit[$i]."
";
}
$i++;
}
}
if ($fld_err)
{
$body_txt .= "
".DBLAN_8." |
".DBLAN_9."
{$xfparams}
".DBLAN_10."
{$fparams}
|
".fix_form($k, $fname, $fparams, "alter")." |
";
$fix_active = TRUE;
$xfield_errors++;
}
/* FIXME - can't stay if there is no way of fixing the field numbers (e.g. AFTER query)
elseif ($fieldnum != $xfieldnum)
{ // Field numbers different - missing field?
$body_txt .= "
".DBLAN_5." ".DBLAN_8." |
".DBLAN_9.": #{$xfieldnum}
".DBLAN_10.": #{$fieldnum}
|
|
";
}
// DISABLED for now (show only errors), could be page setting
// else
// {
// $body_txt .= "
// OK |
// |
// |
// ";
// }
//
}
} // Finished checking one field
if ($ffound == 0)
{
$prev_fname = $fname; //FIXME - wrong $prev_fname!
$body_txt .= "
".DBLAN_11." |
".DBLAN_10."
{$fparams}
|
".fix_form($k, $fname, $fparams, "insert", $prev_fname)." |
";
$fix_active = TRUE;
$xfield_errors++;
}
if($xfield_errors && $body_txt)
{
$ttext .= $head_txt.$body_txt."
";
}
}
foreach(array_keys($xfields) as $tf)
{
if (!$fields[$tf] && $k != "user_extended")
{
$fix_active = TRUE;
$xfield_errors++;
$ttext .= "