Skip to content
Extraits de code Groupes Projets
Valider 98d570cd rédigé par cerdic's avatar cerdic
Parcourir les fichiers

indentation

parent e3ea2fb2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -189,37 +189,37 @@ function spip_connect_db($host, $port, $login, $pass, $db) { ...@@ -189,37 +189,37 @@ function spip_connect_db($host, $port, $login, $pass, $db) {
function spip_mysql_showtable($nom_table) function spip_mysql_showtable($nom_table)
{ {
$a = spip_query("SHOW TABLES LIKE '$nom_table'"); $a = spip_query("SHOW TABLES LIKE '$nom_table'");
if (!a) return ""; if (!a) return "";
if (!spip_fetch_array($a)) return ""; if (!spip_fetch_array($a)) return "";
list(,$a) = spip_fetch_array(spip_query("SHOW CREATE TABLE $nom_table")); list(,$a) = spip_fetch_array(spip_query("SHOW CREATE TABLE $nom_table"));
if (!preg_match("/^[^(),]*\((([^()]*\([^()]*\)[^()]*)*)\)[^()]*$/", $a, $r)) if (!preg_match("/^[^(),]*\((([^()]*\([^()]*\)[^()]*)*)\)[^()]*$/", $a, $r))
return ""; return "";
else { else {
$dec = $r[1]; $dec = $r[1];
if (preg_match("/^(.*?),([^,]*KEY.*)$/s", $dec, $r)) { if (preg_match("/^(.*?),([^,]*KEY.*)$/s", $dec, $r)) {
$namedkeys = $r[2]; $namedkeys = $r[2];
$dec = $r[1]; $dec = $r[1];
} }
else else
$namedkeys = ""; $namedkeys = "";
$fields = array(); $fields = array();
foreach(preg_split("/,\s*`/",$dec) as $v) { foreach(preg_split("/,\s*`/",$dec) as $v) {
preg_match("/^\s*`?([^`]*)`\s*(.*)/",$v,$r); preg_match("/^\s*`?([^`]*)`\s*(.*)/",$v,$r);
$fields[strtolower($r[1])] = $r[2]; $fields[strtolower($r[1])] = $r[2];
} }
$keys = array(); $keys = array();
foreach(preg_split('/\)\s*,?/',$namedkeys) as $v) { foreach(preg_split('/\)\s*,?/',$namedkeys) as $v) {
if (preg_match("/^\s*([^(]*)\((.*)$/",$v,$r)) { if (preg_match("/^\s*([^(]*)\((.*)$/",$v,$r)) {
$k = str_replace("`", '', trim($r[1])); $k = str_replace("`", '', trim($r[1]));
$t = strtolower(str_replace("`", '', $r[2])); $t = strtolower(str_replace("`", '', $r[2]));
if ($k && !isset($keys[$k])) $keys[$k] = $t; else $keys[] = $t; if ($k && !isset($keys[$k])) $keys[$k] = $t; else $keys[] = $t;
} }
} }
return array('field' => $fields, 'key' => $keys); return array('field' => $fields, 'key' => $keys);
} }
} }
// //
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter