Skip to content

Commit

Permalink
or like function
Browse files Browse the repository at this point in the history
  • Loading branch information
vinzentt committed Nov 30, 2011
1 parent c25c7bc commit 9e8aa01
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libraries/Mongo_db.php
Expand Up @@ -527,6 +527,15 @@ public function like($field = "", $value = "", $flags = "i", $enable_start_wildc
return ($this); 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) public function or_like($fields = array(), $value = "", $flags = "i", $enable_start_wildcard = TRUE, $enable_end_wildcard = TRUE)
{ {
// $field = (string) trim($field); // $field = (string) trim($field);
Expand All @@ -547,7 +556,8 @@ public function or_like($fields = array(), $value = "", $flags = "i", $enable_st
$regex = "/$value/$flags"; $regex = "/$value/$flags";
foreach ($fields as $field) 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['$or'][] =array($field => new MongoRegex($regex));
} }
// $this->wheres[$field] = new MongoRegex($regex); // $this->wheres[$field] = new MongoRegex($regex);
Expand Down

0 comments on commit 9e8aa01

Please sign in to comment.