From 2a5a407031e913a3ecb1b368499be33c0bc091d7 Mon Sep 17 00:00:00 2001 From: Matthieu Marcillaud <marcimat@rezo.net> Date: Mon, 10 Dec 2007 18:05:31 +0000 Subject: [PATCH] Il faut ajouter la fonction REGEXP pour sqlite3 et inverser l'ordre des argments aussi. Crayons fonctionnels sur sqlite2 et 3. --- ecrire/req/sqlite_fonctions.php | 5 +++-- ecrire/req/sqlite_generique.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ecrire/req/sqlite_fonctions.php b/ecrire/req/sqlite_fonctions.php index 597bce20a4..87bc7cf595 100644 --- a/ecrire/req/sqlite_fonctions.php +++ b/ecrire/req/sqlite_fonctions.php @@ -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; diff --git a/ecrire/req/sqlite_generique.php b/ecrire/req/sqlite_generique.php index db43cdc209..a9ecadfa16 100644 --- a/ecrire/req/sqlite_generique.php +++ b/ecrire/req/sqlite_generique.php @@ -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); } } -- GitLab