public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
* Fixed SQL query values with 0 length
* You can now use custom operators with SQL interfacing in the form of 
array("foo >" => $bar);
vito (author)
Tue Sep 02 19:26:21 -0700 2008
commit  78eaa182ebd2761dd7dfd29aa524c3fe8a6b1911
tree    320600d0d971b3e552efd0ba6f73668f62645f5e
parent  12a1e446d0674cb95c26b4a44296d94684a4ed15
...
194
195
196
197
 
198
199
200
...
218
219
220
 
 
 
 
 
221
222
223
...
194
195
196
 
197
198
199
200
...
218
219
220
221
222
223
224
225
226
227
228
0
@@ -194,7 +194,7 @@
0
         if (is_int($key)) # Full expression
0
           $cond = $val;
0
         else { # Key => Val expression
0
-          if (is_string($val) and $val[0] == ":")
0
+          if (is_string($val) and strlen($val) and $val[0] == ":")
0
             $cond = $key." = ".$val;
0
           else {
0
             if (substr($key, -4) == " not") { # Negation
0
@@ -218,6 +218,11 @@
0
               $param = str_replace(array("(", ")"), "_", $key);
0
               $cond = $key." NOT LIKE :".$param;
0
               $params[":".$param] = $val;
0
+            } elseif (substr_count($key, " ")) { # Custom operation, e.g. array("foo >" => $bar)
0
+              list($param,) = explode(" ", $key);
0
+              $param = str_replace(array("(", ")"), "_", $param);
0
+              $cond = $key." :".$param;
0
+              $params[":".$param] = $val;
0
             } else { # Equation
0
               if (is_array($val))
0
                 $cond = $key." IN ".self::build_in($val);
...
427
428
429
430
 
431
432
433
...
438
439
440
441
442
 
443
444
445
...
427
428
429
 
430
431
432
433
...
438
439
440
 
 
441
442
443
444
0
@@ -427,7 +427,7 @@
0
             $new_comments = $sql->select("comments",
0
                                          "id",
0
                                          array("post_id" => $_POST['post_id'],
0
-                                               "id > :last_comment",
0
+                                               "id >" => $_POST['last_comment'],
0
                                                "status not" => "spam",
0
                                                "status != 'denied' OR (
0
                                                     (
0
@@ -438,8 +438,7 @@
0
                                                     )
0
                                                 )"),
0
                                          "created_at ASC",
0
-                                         array(":last_comment" => $_POST['last_comment'],
0
-                                               ":visitor_id" => $visitor->id));
0
+                                         array(":visitor_id" => $visitor->id));
0
 
0
             $ids = array();
0
             while ($the_comment = $new_comments->fetchObject())

Comments