@@ -64,27 +64,27 @@ discard block |
||
| 64 | 64 | // determiner le dossier de la base : $addr ou _DIR_DB |
| 65 | 65 | $f = _DIR_DB; |
| 66 | 66 | if ($addr and strpos($addr, '/') !== false) { |
| 67 | - $f = rtrim($addr, '/') . '/'; |
|
| 67 | + $f = rtrim($addr, '/').'/'; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // un nom de base demande et impossible d'obtenir la base, on s'en va : |
| 71 | 71 | // il faut que la base existe ou que le repertoire parent soit writable |
| 72 | - if ($db and !is_file($f .= $db . '.sqlite') and !is_writable(dirname($f))) { |
|
| 73 | - spip_log("base $f non trouvee ou droits en ecriture manquants", 'sqlite.' . _LOG_HS); |
|
| 72 | + if ($db and !is_file($f .= $db.'.sqlite') and !is_writable(dirname($f))) { |
|
| 73 | + spip_log("base $f non trouvee ou droits en ecriture manquants", 'sqlite.'._LOG_HS); |
|
| 74 | 74 | |
| 75 | 75 | return false; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // charger les modules sqlite au besoin |
| 79 | 79 | if (!_sqlite_charger_version($sqlite_version)) { |
| 80 | - spip_log("Impossible de trouver/charger le module SQLite ($sqlite_version)!", 'sqlite.' . _LOG_HS); |
|
| 80 | + spip_log("Impossible de trouver/charger le module SQLite ($sqlite_version)!", 'sqlite.'._LOG_HS); |
|
| 81 | 81 | |
| 82 | 82 | return false; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // chargement des constantes |
| 86 | 86 | // il ne faut pas definir les constantes avant d'avoir charge les modules sqlite |
| 87 | - $define = "spip_sqlite" . $sqlite_version . "_constantes"; |
|
| 87 | + $define = "spip_sqlite".$sqlite_version."_constantes"; |
|
| 88 | 88 | $define(); |
| 89 | 89 | |
| 90 | 90 | $ok = false; |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | // si pas de db -> |
| 93 | 93 | // base temporaire tant qu'on ne connait pas son vrai nom |
| 94 | 94 | // pour tester la connexion |
| 95 | - $db = "_sqlite" . $sqlite_version . "_install"; |
|
| 96 | - $tmp = _DIR_DB . $db . ".sqlite"; |
|
| 95 | + $db = "_sqlite".$sqlite_version."_install"; |
|
| 96 | + $tmp = _DIR_DB.$db.".sqlite"; |
|
| 97 | 97 | $ok = $link = new \PDO("sqlite:$tmp"); |
| 98 | 98 | } else { |
| 99 | 99 | // Ouvrir (eventuellement creer la base) |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | if (!$ok) { |
| 104 | 104 | $e = _sqlite_last_error_from_link($link); |
| 105 | - spip_log("Impossible d'ouvrir la base SQLite($sqlite_version) $f : $e", 'sqlite.' . _LOG_HS); |
|
| 105 | + spip_log("Impossible d'ouvrir la base SQLite($sqlite_version) $f : $e", 'sqlite.'._LOG_HS); |
|
| 106 | 106 | |
| 107 | 107 | return false; |
| 108 | 108 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $table = $regs[3]; |
| 189 | 189 | $suite = $regs[4]; |
| 190 | 190 | } else { |
| 191 | - spip_log("SQLite : Probleme de ALTER TABLE mal forme dans $query", 'sqlite.' . _LOG_ERREUR); |
|
| 191 | + spip_log("SQLite : Probleme de ALTER TABLE mal forme dans $query", 'sqlite.'._LOG_ERREUR); |
|
| 192 | 192 | |
| 193 | 193 | return false; |
| 194 | 194 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $i = 0; |
| 206 | 206 | $ouverte = false; |
| 207 | 207 | while ($do = array_shift($todo)) { |
| 208 | - $todo2[$i] = isset($todo2[$i]) ? $todo2[$i] . "," . $do : $do; |
|
| 208 | + $todo2[$i] = isset($todo2[$i]) ? $todo2[$i].",".$do : $do; |
|
| 209 | 209 | $o = (false !== strpos($do, "(")); |
| 210 | 210 | $f = (false !== strpos($do, ")")); |
| 211 | 211 | if ($o and !$f) { |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | . ')\s*([^\s]*)\s*(.*)?/i', $do, $matches) |
| 230 | 230 | ) { |
| 231 | 231 | spip_log("SQLite : Probleme de ALTER TABLE, utilisation non reconnue dans : $do \n(requete d'origine : $query)", |
| 232 | - 'sqlite.' . _LOG_ERREUR); |
|
| 232 | + 'sqlite.'._LOG_ERREUR); |
|
| 233 | 233 | |
| 234 | 234 | return false; |
| 235 | 235 | } |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // pas geres en sqlite2 |
| 318 | 318 | case 'RENAME': |
| 319 | - $do = "RENAME TO" . substr($do, 6); |
|
| 319 | + $do = "RENAME TO".substr($do, 6); |
|
| 320 | 320 | case 'RENAME TO': |
| 321 | 321 | if (!spip_sqlite::executer_requete("$debut $do", $serveur)) { |
| 322 | - spip_log("SQLite : Erreur ALTER TABLE / RENAME : $query", 'sqlite.' . _LOG_ERREUR); |
|
| 322 | + spip_log("SQLite : Erreur ALTER TABLE / RENAME : $query", 'sqlite.'._LOG_ERREUR); |
|
| 323 | 323 | |
| 324 | 324 | return false; |
| 325 | 325 | } |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $colonnes = substr($colonne_origine, 1, -1); |
| 361 | 361 | if (false !== strpos(",", $colonnes)) { |
| 362 | 362 | spip_log("SQLite : Erreur, impossible de creer un index sur plusieurs colonnes" |
| 363 | - . " sans qu'il ait de nom ($table, ($colonnes))", 'sqlite.' . _LOG_ERREUR); |
|
| 363 | + . " sans qu'il ait de nom ($table, ($colonnes))", 'sqlite.'._LOG_ERREUR); |
|
| 364 | 364 | break; |
| 365 | 365 | } else { |
| 366 | 366 | $nom_index = $colonnes; |
@@ -375,12 +375,12 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | // pas geres en sqlite2 |
| 377 | 377 | case 'ADD COLUMN': |
| 378 | - $do = "ADD" . substr($do, 10); |
|
| 378 | + $do = "ADD".substr($do, 10); |
|
| 379 | 379 | case 'ADD': |
| 380 | 380 | default: |
| 381 | 381 | if (!preg_match(',primary\s+key,i', $do)) { |
| 382 | 382 | if (!spip_sqlite::executer_requete("$debut $do", $serveur)) { |
| 383 | - spip_log("SQLite : Erreur ALTER TABLE / ADD : $query", 'sqlite.' . _LOG_ERREUR); |
|
| 383 | + spip_log("SQLite : Erreur ALTER TABLE / ADD : $query", 'sqlite.'._LOG_ERREUR); |
|
| 384 | 384 | |
| 385 | 385 | return false; |
| 386 | 386 | } |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | } |
| 402 | 402 | $opts['field'] = array($colonne_ajoutee => $def); |
| 403 | 403 | if (!_sqlite_modifier_table($table, array($colonne_ajoutee), $opts, $serveur)) { |
| 404 | - spip_log("SQLite : Erreur ALTER TABLE / ADD : $query", 'sqlite.' . _LOG_ERREUR); |
|
| 404 | + spip_log("SQLite : Erreur ALTER TABLE / ADD : $query", 'sqlite.'._LOG_ERREUR); |
|
| 405 | 405 | |
| 406 | 406 | return false; |
| 407 | 407 | } |
@@ -409,10 +409,10 @@ discard block |
||
| 409 | 409 | break; |
| 410 | 410 | } |
| 411 | 411 | // tout est bon, ouf ! |
| 412 | - spip_log("SQLite ($serveur) : Changements OK : $debut $do", 'sqlite.' . _LOG_INFO); |
|
| 412 | + spip_log("SQLite ($serveur) : Changements OK : $debut $do", 'sqlite.'._LOG_INFO); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - spip_log("SQLite ($serveur) : fin ALTER TABLE OK !", 'sqlite.' . _LOG_INFO); |
|
| 415 | + spip_log("SQLite ($serveur) : fin ALTER TABLE OK !", 'sqlite.'._LOG_INFO); |
|
| 416 | 416 | |
| 417 | 417 | return true; |
| 418 | 418 | } |
@@ -481,9 +481,9 @@ discard block |
||
| 481 | 481 | * @return bool true si la base est créee. |
| 482 | 482 | **/ |
| 483 | 483 | function spip_sqlite_create_base($nom, $serveur = '', $option = true) { |
| 484 | - $f = $nom . '.sqlite'; |
|
| 484 | + $f = $nom.'.sqlite'; |
|
| 485 | 485 | if (strpos($nom, "/") === false) { |
| 486 | - $f = _DIR_DB . $f; |
|
| 486 | + $f = _DIR_DB.$f; |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | $ok = new \PDO("sqlite:$f"); |
@@ -522,12 +522,12 @@ discard block |
||
| 522 | 522 | // vue deja presente |
| 523 | 523 | if (sql_showtable($nom, false, $serveur)) { |
| 524 | 524 | spip_log("Echec creation d'une vue sql ($nom) car celle-ci existe deja (serveur:$serveur)", |
| 525 | - 'sqlite.' . _LOG_ERREUR); |
|
| 525 | + 'sqlite.'._LOG_ERREUR); |
|
| 526 | 526 | |
| 527 | 527 | return false; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - $query = "CREATE VIEW $nom AS " . $query_select; |
|
| 530 | + $query = "CREATE VIEW $nom AS ".$query_select; |
|
| 531 | 531 | |
| 532 | 532 | return spip_sqlite_query($query, $serveur, $requeter); |
| 533 | 533 | } |
@@ -552,15 +552,15 @@ discard block |
||
| 552 | 552 | */ |
| 553 | 553 | function spip_sqlite_create_index($nom, $table, $champs, $unique = '', $serveur = '', $requeter = true) { |
| 554 | 554 | if (!($nom or $table or $champs)) { |
| 555 | - spip_log("Champ manquant pour creer un index sqlite ($nom, $table, (" . join(',', $champs) . "))", |
|
| 556 | - 'sqlite.' . _LOG_ERREUR); |
|
| 555 | + spip_log("Champ manquant pour creer un index sqlite ($nom, $table, (".join(',', $champs)."))", |
|
| 556 | + 'sqlite.'._LOG_ERREUR); |
|
| 557 | 557 | |
| 558 | 558 | return false; |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | // SQLite ne differentie pas noms des index en fonction des tables |
| 562 | 562 | // il faut donc creer des noms uniques d'index pour une base sqlite |
| 563 | - $nom = $table . '_' . $nom; |
|
| 563 | + $nom = $table.'_'.$nom; |
|
| 564 | 564 | // enlever d'eventuelles parentheses deja presentes sur champs |
| 565 | 565 | if (!is_array($champs)) { |
| 566 | 566 | if ($champs[0] == "(") { |
@@ -582,12 +582,12 @@ discard block |
||
| 582 | 582 | } else { |
| 583 | 583 | /* simuler le IF EXISTS - version 2 et sqlite < 3.3a */ |
| 584 | 584 | $a = spip_sqlite_showtable($table, $serveur); |
| 585 | - if (isset($a['key']['KEY ' . $nom])) { |
|
| 585 | + if (isset($a['key']['KEY '.$nom])) { |
|
| 586 | 586 | return true; |
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $query = "CREATE " . ($unique ? "UNIQUE " : "") . "INDEX$ifnotexists $nom ON $table (" . join(',', $champs) . ")"; |
|
| 590 | + $query = "CREATE ".($unique ? "UNIQUE " : "")."INDEX$ifnotexists $nom ON $table (".join(',', $champs).")"; |
|
| 591 | 591 | $res = spip_sqlite_query($query, $serveur, $requeter); |
| 592 | 592 | if (!$requeter) { |
| 593 | 593 | return $res; |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | $serveur = '', |
| 664 | 664 | $requeter = true |
| 665 | 665 | ) { |
| 666 | - $c = !$groupby ? '*' : ('DISTINCT ' . (is_string($groupby) ? $groupby : join(',', $groupby))); |
|
| 666 | + $c = !$groupby ? '*' : ('DISTINCT '.(is_string($groupby) ? $groupby : join(',', $groupby))); |
|
| 667 | 667 | $r = spip_sqlite_select("COUNT($c)", $from, $where, '', '', '', |
| 668 | 668 | $having, $serveur, $requeter); |
| 669 | 669 | if ((is_resource($r) or is_object($r)) && $requeter) { // ressource : sqlite2, object : sqlite3 |
@@ -761,14 +761,14 @@ discard block |
||
| 761 | 761 | */ |
| 762 | 762 | function spip_sqlite_drop_index($nom, $table, $serveur = '', $requeter = true) { |
| 763 | 763 | if (!($nom or $table)) { |
| 764 | - spip_log("Champ manquant pour supprimer un index sqlite ($nom, $table)", 'sqlite.' . _LOG_ERREUR); |
|
| 764 | + spip_log("Champ manquant pour supprimer un index sqlite ($nom, $table)", 'sqlite.'._LOG_ERREUR); |
|
| 765 | 765 | |
| 766 | 766 | return false; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | // SQLite ne differentie pas noms des index en fonction des tables |
| 770 | 770 | // il faut donc creer des noms uniques d'index pour une base sqlite |
| 771 | - $index = $table . '_' . $nom; |
|
| 771 | + $index = $table.'_'.$nom; |
|
| 772 | 772 | $exist = " IF EXISTS"; |
| 773 | 773 | |
| 774 | 774 | $query = "DROP INDEX$exist $index"; |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | if ($s) { |
| 801 | 801 | $trace = debug_backtrace(); |
| 802 | 802 | if ($trace[0]['function'] != "spip_sqlite_error") { |
| 803 | - spip_log("$s - $query - " . sql_error_backtrace(), 'sqlite.' . _LOG_ERREUR); |
|
| 803 | + spip_log("$s - $query - ".sql_error_backtrace(), 'sqlite.'._LOG_ERREUR); |
|
| 804 | 804 | } |
| 805 | 805 | } |
| 806 | 806 | |
@@ -847,14 +847,14 @@ discard block |
||
| 847 | 847 | $t = $link->errorInfo(); |
| 848 | 848 | $s = ltrim($t[0], '0'); // 00000 si pas d'erreur |
| 849 | 849 | if ($s) { |
| 850 | - $s .= ' / ' . $t[1]; |
|
| 850 | + $s .= ' / '.$t[1]; |
|
| 851 | 851 | } // ajoute l'erreur du moteur SQLite |
| 852 | 852 | } else { |
| 853 | 853 | $s = ": aucune ressource sqlite (link)"; |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | if ($s) { |
| 857 | - spip_log("Erreur sqlite $s", 'sqlite.' . _LOG_ERREUR); |
|
| 857 | + spip_log("Erreur sqlite $s", 'sqlite.'._LOG_ERREUR); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | return $s ? $s : 0; |
@@ -878,7 +878,7 @@ discard block |
||
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | $query = spip_sqlite::traduire_requete($query, $serveur); |
| 881 | - $query = 'EXPLAIN ' . $query; |
|
| 881 | + $query = 'EXPLAIN '.$query; |
|
| 882 | 882 | if (!$requeter) { |
| 883 | 883 | return $query; |
| 884 | 884 | } |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | **/ |
| 1039 | 1039 | function spip_sqlite_insert($table, $champs, $valeurs, $desc = array(), $serveur = '', $requeter = true) { |
| 1040 | 1040 | |
| 1041 | - $query = "INSERT INTO $table " . ($champs ? "$champs VALUES $valeurs" : "DEFAULT VALUES"); |
|
| 1041 | + $query = "INSERT INTO $table ".($champs ? "$champs VALUES $valeurs" : "DEFAULT VALUES"); |
|
| 1042 | 1042 | if ($r = spip_sqlite_query($query, $serveur, $requeter)) { |
| 1043 | 1043 | if (!$requeter) { |
| 1044 | 1044 | return $r; |
@@ -1094,8 +1094,8 @@ discard block |
||
| 1094 | 1094 | |
| 1095 | 1095 | $cles = $valeurs = ""; |
| 1096 | 1096 | if (count($couples)) { |
| 1097 | - $cles = "(" . join(',', array_keys($couples)) . ")"; |
|
| 1098 | - $valeurs = "(" . join(',', $couples) . ")"; |
|
| 1097 | + $cles = "(".join(',', array_keys($couples)).")"; |
|
| 1098 | + $valeurs = "(".join(',', $couples).")"; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | return spip_sqlite_insert($table, $cles, $valeurs, $desc, $serveur, $requeter); |
@@ -1155,11 +1155,11 @@ discard block |
||
| 1155 | 1155 | |
| 1156 | 1156 | $champs = $valeurs = ""; |
| 1157 | 1157 | if (count($couples)) { |
| 1158 | - $champs = "(" . join(',', array_keys($couples)) . ")"; |
|
| 1159 | - $valeurs = "(" . join(',', $couples) . ")"; |
|
| 1160 | - $query = $query_start . "$champs VALUES $valeurs"; |
|
| 1158 | + $champs = "(".join(',', array_keys($couples)).")"; |
|
| 1159 | + $valeurs = "(".join(',', $couples).")"; |
|
| 1160 | + $query = $query_start."$champs VALUES $valeurs"; |
|
| 1161 | 1161 | } else { |
| 1162 | - $query = $query_start . "DEFAULT VALUES"; |
|
| 1162 | + $query = $query_start."DEFAULT VALUES"; |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | if ($requeter) { |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | * @return string Texte de sélection pour la requête |
| 1292 | 1292 | */ |
| 1293 | 1293 | function spip_sqlite_multi($objet, $lang) { |
| 1294 | - $r = "EXTRAIRE_MULTI(" . $objet . ", '" . $lang . "') AS multi"; |
|
| 1294 | + $r = "EXTRAIRE_MULTI(".$objet.", '".$lang."') AS multi"; |
|
| 1295 | 1295 | |
| 1296 | 1296 | return $r; |
| 1297 | 1297 | } |
@@ -1362,7 +1362,7 @@ discard block |
||
| 1362 | 1362 | function spip_sqlite_date_proche($champ, $interval, $unite) { |
| 1363 | 1363 | $op = (($interval <= 0) ? '>' : '<'); |
| 1364 | 1364 | |
| 1365 | - return "($champ $op datetime('" . date("Y-m-d H:i:s") . "', '$interval $unite'))"; |
|
| 1365 | + return "($champ $op datetime('".date("Y-m-d H:i:s")."', '$interval $unite'))"; |
|
| 1366 | 1366 | } |
| 1367 | 1367 | |
| 1368 | 1368 | |
@@ -1392,7 +1392,7 @@ discard block |
||
| 1392 | 1392 | and (!isset($desc['key']['PRIMARY KEY']) or $desc['key']['PRIMARY KEY'] !== $c) |
| 1393 | 1393 | ) { |
| 1394 | 1394 | spip_sqlite_alter($q = "TABLE $table CHANGE $c $c $d DEFAULT ''", $serveur); |
| 1395 | - spip_log("ALTER $q", "repair" . _LOG_INFO_IMPORTANTE); |
|
| 1395 | + spip_log("ALTER $q", "repair"._LOG_INFO_IMPORTANTE); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | if (preg_match(",^(INTEGER),i", $d) |
| 1398 | 1398 | and stripos($d, "NOT NULL") !== false |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | and (!isset($desc['key']['PRIMARY KEY']) or $desc['key']['PRIMARY KEY'] !== $c) |
| 1402 | 1402 | ) { |
| 1403 | 1403 | spip_sqlite_alter($q = "TABLE $table CHANGE $c $c $d DEFAULT '0'", $serveur); |
| 1404 | - spip_log("ALTER $q", "repair" . _LOG_INFO_IMPORTANTE); |
|
| 1404 | + spip_log("ALTER $q", "repair"._LOG_INFO_IMPORTANTE); |
|
| 1405 | 1405 | } |
| 1406 | 1406 | if (preg_match(",^(datetime),i", $d) |
| 1407 | 1407 | and stripos($d, "NOT NULL") !== false |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | and (!isset($desc['key']['PRIMARY KEY']) or $desc['key']['PRIMARY KEY'] !== $c) |
| 1411 | 1411 | ) { |
| 1412 | 1412 | spip_sqlite_alter($q = "TABLE $table CHANGE $c $c $d DEFAULT '0000-00-00 00:00:00'", $serveur); |
| 1413 | - spip_log("ALTER $q", "repair" . _LOG_INFO_IMPORTANTE); |
|
| 1413 | + spip_log("ALTER $q", "repair"._LOG_INFO_IMPORTANTE); |
|
| 1414 | 1414 | } |
| 1415 | 1415 | } |
| 1416 | 1416 | |
@@ -1461,8 +1461,8 @@ discard block |
||
| 1461 | 1461 | // recherche de champs 'timestamp' pour mise a jour auto de ceux-ci |
| 1462 | 1462 | $couples = _sqlite_ajouter_champs_timestamp($table, $couples, $desc, $serveur); |
| 1463 | 1463 | |
| 1464 | - return spip_sqlite_query("REPLACE INTO $table (" . join(',', array_keys($couples)) . ') VALUES (' . join(',', |
|
| 1465 | - $couples) . ')', $serveur); |
|
| 1464 | + return spip_sqlite_query("REPLACE INTO $table (".join(',', array_keys($couples)).') VALUES ('.join(',', |
|
| 1465 | + $couples).')', $serveur); |
|
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | 1468 | |
@@ -1548,7 +1548,7 @@ discard block |
||
| 1548 | 1548 | . _sqlite_calculer_expression('WHERE', $where) |
| 1549 | 1549 | . _sqlite_calculer_expression('GROUP BY', $groupby, ',') |
| 1550 | 1550 | . _sqlite_calculer_expression('HAVING', $having) |
| 1551 | - . ($orderby ? ("\nORDER BY " . _sqlite_calculer_order($orderby)) : '') |
|
| 1551 | + . ($orderby ? ("\nORDER BY "._sqlite_calculer_order($orderby)) : '') |
|
| 1552 | 1552 | . ($limit ? "\nLIMIT $limit" : ''); |
| 1553 | 1553 | |
| 1554 | 1554 | // dans un select, on doit renvoyer la requête en cas d'erreur |
@@ -1585,10 +1585,10 @@ discard block |
||
| 1585 | 1585 | |
| 1586 | 1586 | // interdire la creation d'une nouvelle base, |
| 1587 | 1587 | // sauf si on est dans l'installation |
| 1588 | - if (!is_file($f = _DIR_DB . $db . '.sqlite') |
|
| 1588 | + if (!is_file($f = _DIR_DB.$db.'.sqlite') |
|
| 1589 | 1589 | && (!defined('_ECRIRE_INSTALL') || !_ECRIRE_INSTALL) |
| 1590 | 1590 | ) { |
| 1591 | - spip_log("Il est interdit de creer la base $db", 'sqlite.' . _LOG_HS); |
|
| 1591 | + spip_log("Il est interdit de creer la base $db", 'sqlite.'._LOG_HS); |
|
| 1592 | 1592 | |
| 1593 | 1593 | return false; |
| 1594 | 1594 | } |
@@ -1597,12 +1597,12 @@ discard block |
||
| 1597 | 1597 | // avec les identifiants connus |
| 1598 | 1598 | $index = $serveur ? $serveur : 0; |
| 1599 | 1599 | |
| 1600 | - if ($link = spip_connect_db('', '', '', '', '@selectdb@' . $db, $serveur, '', '')) { |
|
| 1600 | + if ($link = spip_connect_db('', '', '', '', '@selectdb@'.$db, $serveur, '', '')) { |
|
| 1601 | 1601 | if (($db == $link['db']) && $GLOBALS['connexions'][$index] = $link) { |
| 1602 | 1602 | return $db; |
| 1603 | 1603 | } |
| 1604 | 1604 | } else { |
| 1605 | - spip_log("Impossible de selectionner la base $db", 'sqlite.' . _LOG_HS); |
|
| 1605 | + spip_log("Impossible de selectionner la base $db", 'sqlite.'._LOG_HS); |
|
| 1606 | 1606 | |
| 1607 | 1607 | return false; |
| 1608 | 1608 | } |
@@ -1653,7 +1653,7 @@ discard block |
||
| 1653 | 1653 | $match = str_replace("[[POURCENT]]", "%", $match); |
| 1654 | 1654 | $match = "^$match$"; |
| 1655 | 1655 | |
| 1656 | - return spip_sqlite_query("SELECT name FROM sqlite_master WHERE type='table' AND tbl_name REGEXP " . _q($match), |
|
| 1656 | + return spip_sqlite_query("SELECT name FROM sqlite_master WHERE type='table' AND tbl_name REGEXP "._q($match), |
|
| 1657 | 1657 | $serveur, $requeter); |
| 1658 | 1658 | } |
| 1659 | 1659 | |
@@ -1743,7 +1743,7 @@ discard block |
||
| 1743 | 1743 | // s'il y a une parenthèse fermante dans la clé |
| 1744 | 1744 | // ou dans la définition sans qu'il n'y ait une ouverture avant |
| 1745 | 1745 | if (false !== strpos($k, ')') or preg_match('/^[^\(]*\)/', $def)) { |
| 1746 | - $fields[$k_precedent] .= ',' . $k . ' ' . $def; |
|
| 1746 | + $fields[$k_precedent] .= ','.$k.' '.$def; |
|
| 1747 | 1747 | continue; |
| 1748 | 1748 | } |
| 1749 | 1749 | |
@@ -1778,13 +1778,13 @@ discard block |
||
| 1778 | 1778 | . 'ORDER BY substr(type,2,1), name'; |
| 1779 | 1779 | $a = spip_sqlite_query($query, $serveur, $requeter); |
| 1780 | 1780 | while ($r = spip_sqlite_fetch($a, null, $serveur)) { |
| 1781 | - $key = str_replace($nom_table . '_', '', $r['name']); // enlever le nom de la table ajoute a l'index |
|
| 1781 | + $key = str_replace($nom_table.'_', '', $r['name']); // enlever le nom de la table ajoute a l'index |
|
| 1782 | 1782 | $keytype = "KEY"; |
| 1783 | 1783 | if (strpos($r['sql'], "UNIQUE INDEX") !== false) { |
| 1784 | 1784 | $keytype = "UNIQUE KEY"; |
| 1785 | 1785 | } |
| 1786 | 1786 | $colonnes = preg_replace(',.*\((.*)\).*,', '$1', $r['sql']); |
| 1787 | - $keys[$keytype . ' ' . $key] = $colonnes; |
|
| 1787 | + $keys[$keytype.' '.$key] = $colonnes; |
|
| 1788 | 1788 | } |
| 1789 | 1789 | } |
| 1790 | 1790 | |
@@ -1833,7 +1833,7 @@ discard block |
||
| 1833 | 1833 | |
| 1834 | 1834 | $set = array(); |
| 1835 | 1835 | foreach ($champs as $champ => $val) { |
| 1836 | - $set[] = $champ . "=$val"; |
|
| 1836 | + $set[] = $champ."=$val"; |
|
| 1837 | 1837 | } |
| 1838 | 1838 | if (!empty($set)) { |
| 1839 | 1839 | return spip_sqlite_query( |
@@ -1884,7 +1884,7 @@ discard block |
||
| 1884 | 1884 | |
| 1885 | 1885 | $set = array(); |
| 1886 | 1886 | foreach ($champs as $champ => $val) { |
| 1887 | - $set[$champ] = $champ . '=' . _sqlite_calculer_cite($val, isset($fields[$champ]) ? $fields[$champ] : ''); |
|
| 1887 | + $set[$champ] = $champ.'='._sqlite_calculer_cite($val, isset($fields[$champ]) ? $fields[$champ] : ''); |
|
| 1888 | 1888 | } |
| 1889 | 1889 | |
| 1890 | 1890 | // recherche de champs 'timestamp' pour mise a jour auto de ceux-ci |
@@ -1892,7 +1892,7 @@ discard block |
||
| 1892 | 1892 | $maj = _sqlite_ajouter_champs_timestamp($table, [], $desc, $serveur); |
| 1893 | 1893 | foreach ($maj as $champ => $val) { |
| 1894 | 1894 | if (!isset($set[$champ])) { |
| 1895 | - $set[$champ] = $champ . '=' . $val; |
|
| 1895 | + $set[$champ] = $champ.'='.$val; |
|
| 1896 | 1896 | } |
| 1897 | 1897 | } |
| 1898 | 1898 | |
@@ -1919,7 +1919,7 @@ discard block |
||
| 1919 | 1919 | */ |
| 1920 | 1920 | function _sqlite_init() { |
| 1921 | 1921 | if (!defined('_DIR_DB')) { |
| 1922 | - define('_DIR_DB', _DIR_ETC . 'bases/'); |
|
| 1922 | + define('_DIR_DB', _DIR_ETC.'bases/'); |
|
| 1923 | 1923 | } |
| 1924 | 1924 | if (!defined('_SQLITE_CHMOD')) { |
| 1925 | 1925 | define('_SQLITE_CHMOD', _SPIP_CHMOD); |
@@ -2025,9 +2025,9 @@ discard block |
||
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | 2027 | // echapper les ' en '' |
| 2028 | - spip_log("Pas de methode ->quote pour echapper", "sqlite." . _LOG_INFO_IMPORTANTE); |
|
| 2028 | + spip_log("Pas de methode ->quote pour echapper", "sqlite."._LOG_INFO_IMPORTANTE); |
|
| 2029 | 2029 | |
| 2030 | - return ("'" . str_replace("'", "''", $v) . "'"); |
|
| 2030 | + return ("'".str_replace("'", "''", $v)."'"); |
|
| 2031 | 2031 | } |
| 2032 | 2032 | |
| 2033 | 2033 | |
@@ -2050,12 +2050,12 @@ discard block |
||
| 2050 | 2050 | $exp = "\n$expression "; |
| 2051 | 2051 | |
| 2052 | 2052 | if (!is_array($v)) { |
| 2053 | - return $exp . $v; |
|
| 2053 | + return $exp.$v; |
|
| 2054 | 2054 | } else { |
| 2055 | 2055 | if (strtoupper($join) === 'AND') { |
| 2056 | - return $exp . join("\n\t$join ", array_map('_sqlite_calculer_where', $v)); |
|
| 2056 | + return $exp.join("\n\t$join ", array_map('_sqlite_calculer_where', $v)); |
|
| 2057 | 2057 | } else { |
| 2058 | - return $exp . join($join, $v); |
|
| 2058 | + return $exp.join($join, $v); |
|
| 2059 | 2059 | } |
| 2060 | 2060 | } |
| 2061 | 2061 | } |
@@ -2089,17 +2089,17 @@ discard block |
||
| 2089 | 2089 | if (substr($k, -1) == '@') { |
| 2090 | 2090 | // c'est une jointure qui se refere au from precedent |
| 2091 | 2091 | // pas de virgule |
| 2092 | - $res .= ' ' . $v; |
|
| 2092 | + $res .= ' '.$v; |
|
| 2093 | 2093 | } else { |
| 2094 | 2094 | if (!is_numeric($k)) { |
| 2095 | 2095 | $p = strpos($v, " "); |
| 2096 | 2096 | if ($p) { |
| 2097 | - $v = substr($v, 0, $p) . " AS '$k'" . substr($v, $p); |
|
| 2097 | + $v = substr($v, 0, $p)." AS '$k'".substr($v, $p); |
|
| 2098 | 2098 | } else { |
| 2099 | 2099 | $v .= " AS '$k'"; |
| 2100 | 2100 | } |
| 2101 | 2101 | } |
| 2102 | - $res .= ', ' . $v; |
|
| 2102 | + $res .= ', '.$v; |
|
| 2103 | 2103 | } |
| 2104 | 2104 | } |
| 2105 | 2105 | |
@@ -2237,13 +2237,13 @@ discard block |
||
| 2237 | 2237 | |
| 2238 | 2238 | $def_origine = sql_showtable($table_origine, false, $serveur); |
| 2239 | 2239 | if (!$def_origine or !isset($def_origine['field'])) { |
| 2240 | - spip_log("Alter table impossible sur $table_origine : table non trouvee", 'sqlite' . _LOG_ERREUR); |
|
| 2240 | + spip_log("Alter table impossible sur $table_origine : table non trouvee", 'sqlite'._LOG_ERREUR); |
|
| 2241 | 2241 | |
| 2242 | 2242 | return false; |
| 2243 | 2243 | } |
| 2244 | 2244 | |
| 2245 | 2245 | |
| 2246 | - $table_tmp = $table_origine . '_tmp'; |
|
| 2246 | + $table_tmp = $table_origine.'_tmp'; |
|
| 2247 | 2247 | |
| 2248 | 2248 | // 1) creer une table temporaire avec les modifications |
| 2249 | 2249 | // - DROP : suppression de la colonne |
@@ -2329,7 +2329,7 @@ discard block |
||
| 2329 | 2329 | } else { |
| 2330 | 2330 | // enlever KEY |
| 2331 | 2331 | $k = substr($k, 4); |
| 2332 | - $queries[] = "CREATE INDEX $table_destination" . "_$k ON $table_destination ($v)"; |
|
| 2332 | + $queries[] = "CREATE INDEX $table_destination"."_$k ON $table_destination ($v)"; |
|
| 2333 | 2333 | } |
| 2334 | 2334 | } |
| 2335 | 2335 | |
@@ -2340,7 +2340,7 @@ discard block |
||
| 2340 | 2340 | foreach ($queries as $q) { |
| 2341 | 2341 | if (!spip_sqlite::executer_requete($q, $serveur)) { |
| 2342 | 2342 | spip_log("SQLite : ALTER TABLE table :" |
| 2343 | - . " Erreur a l'execution de la requete : $q", 'sqlite.' . _LOG_ERREUR); |
|
| 2343 | + . " Erreur a l'execution de la requete : $q", 'sqlite.'._LOG_ERREUR); |
|
| 2344 | 2344 | spip_sqlite::annuler_transaction($serveur); |
| 2345 | 2345 | |
| 2346 | 2346 | return false; |
@@ -2429,27 +2429,27 @@ discard block |
||
| 2429 | 2429 | $enum = "(\s*\([^\)]*\))?"; |
| 2430 | 2430 | |
| 2431 | 2431 | $remplace = array( |
| 2432 | - '/enum' . $enum . '/is' => 'VARCHAR(255)', |
|
| 2432 | + '/enum'.$enum.'/is' => 'VARCHAR(255)', |
|
| 2433 | 2433 | '/COLLATE \w+_bin/is' => 'COLLATE BINARY', |
| 2434 | 2434 | '/COLLATE \w+_ci/is' => 'COLLATE NOCASE', |
| 2435 | 2435 | '/auto_increment/is' => '', |
| 2436 | 2436 | '/current_timestamp\(\)/is' => 'CURRENT_TIMESTAMP', // Fix export depuis mariaDB #4374 |
| 2437 | 2437 | '/(timestamp .* )ON .*$/is' => '\\1', |
| 2438 | 2438 | '/character set \w+/is' => '', |
| 2439 | - '/((big|small|medium|tiny)?int(eger)?)' . $num . '\s*unsigned/is' => '\\1 UNSIGNED', |
|
| 2439 | + '/((big|small|medium|tiny)?int(eger)?)'.$num.'\s*unsigned/is' => '\\1 UNSIGNED', |
|
| 2440 | 2440 | '/(text\s+not\s+null(\s+collate\s+\w+)?)\s*$/is' => "\\1 DEFAULT ''", |
| 2441 | - '/((char|varchar)' . $num . '\s+not\s+null(\s+collate\s+\w+)?)\s*$/is' => "\\1 DEFAULT ''", |
|
| 2441 | + '/((char|varchar)'.$num.'\s+not\s+null(\s+collate\s+\w+)?)\s*$/is' => "\\1 DEFAULT ''", |
|
| 2442 | 2442 | '/(datetime\s+not\s+null)\s*$/is' => "\\1 DEFAULT '0000-00-00 00:00:00'", |
| 2443 | 2443 | '/(date\s+not\s+null)\s*$/is' => "\\1 DEFAULT '0000-00-00'", |
| 2444 | 2444 | ); |
| 2445 | 2445 | |
| 2446 | 2446 | // pour l'autoincrement, il faut des INTEGER NOT NULL PRIMARY KEY |
| 2447 | 2447 | $remplace_autocinc = array( |
| 2448 | - '/(big|small|medium|tiny)?int(eger)?' . $num . '/is' => 'INTEGER' |
|
| 2448 | + '/(big|small|medium|tiny)?int(eger)?'.$num.'/is' => 'INTEGER' |
|
| 2449 | 2449 | ); |
| 2450 | 2450 | // pour les int non autoincrement, il faut un DEFAULT |
| 2451 | 2451 | $remplace_nonautocinc = array( |
| 2452 | - '/((big|small|medium|tiny)?int(eger)?' . $num . '\s+not\s+null)\s*$/is' => "\\1 DEFAULT 0", |
|
| 2452 | + '/((big|small|medium|tiny)?int(eger)?'.$num.'\s+not\s+null)\s*$/is' => "\\1 DEFAULT 0", |
|
| 2453 | 2453 | ); |
| 2454 | 2454 | |
| 2455 | 2455 | if (is_string($query)) { |
@@ -2491,7 +2491,7 @@ discard block |
||
| 2491 | 2491 | return str_ireplace("BINARY", "COLLATE BINARY", $champ); |
| 2492 | 2492 | } |
| 2493 | 2493 | if (preg_match(",^(char|varchar|(long|small|medium|tiny)?text),i", $champ)) { |
| 2494 | - return $champ . " COLLATE NOCASE"; |
|
| 2494 | + return $champ." COLLATE NOCASE"; |
|
| 2495 | 2495 | } |
| 2496 | 2496 | |
| 2497 | 2497 | return $champ; |
@@ -2578,7 +2578,7 @@ discard block |
||
| 2578 | 2578 | } else { |
| 2579 | 2579 | /* simuler le IF EXISTS - version 2 et sqlite < 3.3a */ |
| 2580 | 2580 | $a = spip_sqlite_showtable($nom, $serveur); |
| 2581 | - if (isset($a['key']['KEY ' . $nom])) { |
|
| 2581 | + if (isset($a['key']['KEY '.$nom])) { |
|
| 2582 | 2582 | return true; |
| 2583 | 2583 | } |
| 2584 | 2584 | } |
@@ -2586,7 +2586,7 @@ discard block |
||
| 2586 | 2586 | } |
| 2587 | 2587 | |
| 2588 | 2588 | $temporary = $temporary ? ' TEMPORARY' : ''; |
| 2589 | - $q = "CREATE$temporary TABLE$ifnotexists $nom ($query" . ($keys ? ",$keys" : '') . ")\n"; |
|
| 2589 | + $q = "CREATE$temporary TABLE$ifnotexists $nom ($query".($keys ? ",$keys" : '').")\n"; |
|
| 2590 | 2590 | |
| 2591 | 2591 | return $q; |
| 2592 | 2592 | } |
@@ -2807,7 +2807,7 @@ discard block |
||
| 2807 | 2807 | $this->serveur = strtolower($serveur); |
| 2808 | 2808 | |
| 2809 | 2809 | if (!($this->link = _sqlite_link($this->serveur)) && (!defined('_ECRIRE_INSTALL') || !_ECRIRE_INSTALL)) { |
| 2810 | - spip_log("Aucune connexion sqlite (link)", 'sqlite.' . _LOG_ERREUR); |
|
| 2810 | + spip_log("Aucune connexion sqlite (link)", 'sqlite.'._LOG_ERREUR); |
|
| 2811 | 2811 | |
| 2812 | 2812 | return false; |
| 2813 | 2813 | } |
@@ -2853,7 +2853,7 @@ discard block |
||
| 2853 | 2853 | try { |
| 2854 | 2854 | $r = $this->link->query($query); |
| 2855 | 2855 | } catch (\PDOException $e) { |
| 2856 | - spip_log("PDOException: " . $e->getMessage(), 'sqlite.' . _LOG_DEBUG); |
|
| 2856 | + spip_log("PDOException: ".$e->getMessage(), 'sqlite.'._LOG_DEBUG); |
|
| 2857 | 2857 | $r = false; |
| 2858 | 2858 | } |
| 2859 | 2859 | // sauvegarde de la requete (elle y est deja dans $r->queryString) |
@@ -2874,11 +2874,11 @@ discard block |
||
| 2874 | 2874 | |
| 2875 | 2875 | // loger les warnings/erreurs eventuels de sqlite remontant dans PHP |
| 2876 | 2876 | if ($e and $e instanceof \PDOException) { |
| 2877 | - $err = strip_tags($e->getMessage()) . " in " . $e->getFile() . " line " . $e->getLine(); |
|
| 2878 | - spip_log("$err - " . $query, 'sqlite.' . _LOG_ERREUR); |
|
| 2877 | + $err = strip_tags($e->getMessage())." in ".$e->getFile()." line ".$e->getLine(); |
|
| 2878 | + spip_log("$err - ".$query, 'sqlite.'._LOG_ERREUR); |
|
| 2879 | 2879 | } elseif ($err = (function_exists('error_get_last') ? error_get_last() : "") and $err != $last_error) { |
| 2880 | - $err = strip_tags($err['message']) . " in " . $err['file'] . " line " . $err['line']; |
|
| 2881 | - spip_log("$err - " . $query, 'sqlite.' . _LOG_ERREUR); |
|
| 2880 | + $err = strip_tags($err['message'])." in ".$err['file']." line ".$err['line']; |
|
| 2881 | + spip_log("$err - ".$query, 'sqlite.'._LOG_ERREUR); |
|
| 2882 | 2882 | } else { |
| 2883 | 2883 | $err = ""; |
| 2884 | 2884 | } |
@@ -2957,15 +2957,15 @@ discard block |
||
| 2957 | 2957 | // Correction Create Database |
| 2958 | 2958 | // Create Database -> requete ignoree |
| 2959 | 2959 | if (strpos($this->query, 'CREATE DATABASE') === 0) { |
| 2960 | - spip_log("Sqlite : requete non executee -> $this->query", 'sqlite.' . _LOG_AVERTISSEMENT); |
|
| 2960 | + spip_log("Sqlite : requete non executee -> $this->query", 'sqlite.'._LOG_AVERTISSEMENT); |
|
| 2961 | 2961 | $this->query = "SELECT 1"; |
| 2962 | 2962 | } |
| 2963 | 2963 | |
| 2964 | 2964 | // Correction Insert Ignore |
| 2965 | 2965 | // INSERT IGNORE -> insert (tout court et pas 'insert or replace') |
| 2966 | 2966 | if (strpos($this->query, 'INSERT IGNORE') === 0) { |
| 2967 | - spip_log("Sqlite : requete transformee -> $this->query", 'sqlite.' . _LOG_DEBUG); |
|
| 2968 | - $this->query = 'INSERT ' . substr($this->query, '13'); |
|
| 2967 | + spip_log("Sqlite : requete transformee -> $this->query", 'sqlite.'._LOG_DEBUG); |
|
| 2968 | + $this->query = 'INSERT '.substr($this->query, '13'); |
|
| 2969 | 2969 | } |
| 2970 | 2970 | |
| 2971 | 2971 | // Correction des dates avec INTERVAL |
@@ -2990,7 +2990,7 @@ discard block |
||
| 2990 | 2990 | // problematique car la jointure ne se fait pas du coup. |
| 2991 | 2991 | if (($this->sqlite_version == 2) && (strpos($this->query, "USING") !== false)) { |
| 2992 | 2992 | spip_log("'USING (champ)' n'est pas reconnu en SQLite 2. Utilisez 'ON table1.champ = table2.champ'", |
| 2993 | - 'sqlite.' . _LOG_ERREUR); |
|
| 2993 | + 'sqlite.'._LOG_ERREUR); |
|
| 2994 | 2994 | $this->query = preg_replace('/USING\s*\([^\)]*\)/', '', $this->query); |
| 2995 | 2995 | } |
| 2996 | 2996 | |
@@ -3010,8 +3010,8 @@ discard block |
||
| 3010 | 3010 | } else { |
| 3011 | 3011 | $suite = ''; |
| 3012 | 3012 | } |
| 3013 | - $pref = ($this->prefixe) ? $this->prefixe . "_" : ""; |
|
| 3014 | - $this->query = preg_replace('/([,\s])spip_/S', '\1' . $pref, $this->query) . $suite; |
|
| 3013 | + $pref = ($this->prefixe) ? $this->prefixe."_" : ""; |
|
| 3014 | + $this->query = preg_replace('/([,\s])spip_/S', '\1'.$pref, $this->query).$suite; |
|
| 3015 | 3015 | |
| 3016 | 3016 | // Correction zero AS x |
| 3017 | 3017 | // pg n'aime pas 0+x AS alias, sqlite, dans le meme style, |