]> git.nbdom.net Git - nb.git/commitdiff
str_match
authorNicolas Boisselier <nicolas.boisselier@semantico.com>
Tue, 26 Jul 2016 14:05:23 +0000 (15:05 +0100)
committerNicolas Boisselier <nicolas.boisselier@semantico.com>
Tue, 26 Jul 2016 14:05:23 +0000 (15:05 +0100)
lib/php/db/table.php
lib/php/nb.php

index 5396f566b41af05f5cd404b083aa380395ffb7d8..edcc861f2a323343382d5b5310dc47bc48c0ae14 100644 (file)
@@ -546,6 +546,12 @@ Class Table extends nb {
       $not = strpos($v,'!')===0 ? 1 : 0;
       if ($not) $v = substr($v,1);
 
+      // Superior / Inferior
+      if (preg_match('/^(<|>|<=|>=)/',$v,$m)) {
+        $v = substr($v,strlen($m[1]));
+        $equal = $m[1];
+      }
+
       // Regex
       if (strpos($v,'~')===0) {
         $v = substr($v,1);
@@ -567,7 +573,7 @@ Class Table extends nb {
         if (preg_match('/[_%]/',$v)) {
           $equal = ' '.($not ? 'NOT ' : '').'LIKE ';
         } else {
-          $equal = ($not ? '<> ' : '=');
+          $equal = ($not ? '<> ' : $equal);
         }
 
       // Others
@@ -582,7 +588,7 @@ Class Table extends nb {
           $v = $this->db()->quote($v);
 
         }
-        $equal = $not ? '<>' : '=';
+        $equal = $not ? '<>' : $equal;
 
       }
 
index fef5f436dfbf3a9558a7f6c124a6f9cef4999473..628a280cdfc5e2996246df045446dd35e008cff7 100644 (file)
@@ -542,6 +542,22 @@ class NB {
         $pattern = substr($pattern,1);
         $match = preg_match('@'.str_replace('@','\@',$pattern).'@i',$string);
 
+      // Superior
+      } elseif (strpos($pattern,'>')===0) {
+        $pattern = substr($pattern,1);
+        $match = ($string > $pattern);
+      } elseif (strpos($pattern,'>=')===0) {
+        $pattern = substr($pattern,2);
+        $match = ($string >= $pattern);
+
+      // Inferior
+      } elseif (strpos($pattern,'<')===0) {
+        $pattern = substr($pattern,1);
+        $match = ($string < $pattern);
+      } elseif (strpos($pattern,'<=')===0) {
+        $pattern = substr($pattern,2);
+        $match = ($string <= $pattern);
+
       // Match
       } elseif(preg_match('/['.preg_quote('*?[]!').']/',$pattern)) {