Permalink
Browse files

or like function

  • Loading branch information...
1 parent c25c7bc commit 9e8aa010cfc4c0b8e7fc04407327c1fad4a5beba @vinzentt committed Nov 30, 2011
Showing with 11 additions and 1 deletion.
  1. +11 −1 libraries/Mongo_db.php
View
@@ -527,6 +527,15 @@ public function like($field = "", $value = "", $flags = "i", $enable_start_wildc
return ($this);
}
+ /**
+ * --------------------------------------------------------------------------------
+ * OR Like
+ * --------------------------------------------------------------------------------
+ *
+ *
+ * @usage : $this->mongo_db->like('foo', 'bar', 'im', FALSE, TRUE);
+ */
+
public function or_like($fields = array(), $value = "", $flags = "i", $enable_start_wildcard = TRUE, $enable_end_wildcard = TRUE)
{
// $field = (string) trim($field);
@@ -547,7 +556,8 @@ public function or_like($fields = array(), $value = "", $flags = "i", $enable_st
$regex = "/$value/$flags";
foreach ($fields as $field)
{
- // $this->_where_init($field);
+ $this->_where_init($field);
+ $field = (string) trim($field);
$this->wheres['$or'][] =array($field => new MongoRegex($regex));
}
// $this->wheres[$field] = new MongoRegex($regex);

0 comments on commit 9e8aa01

Please sign in to comment.