Skip to content
Extraits de code Groupes Projets
Valider 2a5a4070 rédigé par marcimat's avatar marcimat
Parcourir les fichiers

Il faut ajouter la fonction REGEXP pour sqlite3 et inverser l'ordre des...

Il faut ajouter la fonction REGEXP pour sqlite3 et inverser l'ordre des argments aussi. Crayons fonctionnels sur sqlite2 et 3.
parent 0b9ff22b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -43,7 +43,8 @@ function _sqlite_init_functions(&$sqlite){
'MONTH' => array( '_sqlite_func_month' ,1),
'RAND' => array( '_sqlite_func_rand' ,0), // sinon random() v2.4
'REGEXP_MATCH' => array( '_sqlite_func_regexp_match' ,2), // critere REGEXP supporte a partir de v3.3.2
'REGEXP' => array( '_sqlite_func_regexp_match' ,2), // critere REGEXP supporte a partir de v3.3.2
//'REGEXP_MATCH' => array( '_sqlite_func_regexp_match' ,2), // critere REGEXP supporte a partir de v3.3.2
'REGEXP_REPLACE'=> array( '_sqlite_func_regexp_replace' ,3),
'RIGHT' => array( '_sqlite_func_right' ,2),
# 'RTRIM' => array( 'rtrim' ,1), // present en theorie
......@@ -179,7 +180,7 @@ function _sqlite_func_right ($s, $lenght) {
}
function _sqlite_func_regexp_match($quoi, $cherche) {
function _sqlite_func_regexp_match($cherche, $quoi) {
$return = preg_match('%'.$cherche.'%', $quoi);
#spip_log("regexp_replace : $quoi, $cherche, $remplace, $return",'debug');
return $return;
......
......@@ -1084,7 +1084,7 @@ class sqlite_analyse_query {
// critere REGEXP non reconnu en sqlite2
function corrigerRegexp(){
if (($this->sqlite_version == 2) && (strpos($this->query, 'REGEXP')!==false)){
$this->query = preg_replace('/([^\s\(]*)(\s*)REGEXP(\s*)([^\s\)]*)/', 'REGEXP_MATCH($1, $4)', $this->query);
$this->query = preg_replace('/([^\s\(]*)(\s*)REGEXP(\s*)([^\s\)]*)/', 'REGEXP($4, $1)', $this->query);
}
}
......
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