Skip to content

Commit

Permalink
MongoID generator..
Browse files Browse the repository at this point in the history
  • Loading branch information
Seyhan Yıldız committed Nov 30, 2018
1 parent a569a30 commit 65fc5f5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/mongoq.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@ class mongoq
*/
public static function ObjectID($id)
{
if(is_int($id)){
if (is_int($id)) {
$id = sprintf("%024d", $id);
}
return new ObjectId($id);
}

/**
* create MongoId
* @return \MongoId
*/
public static function CreateObjectID()
{
return new \MongoId();
}

public function limit($limit = 1)
{
$this->options['limit'] = $limit;
Expand Down Expand Up @@ -322,7 +331,7 @@ public function where($data, $value = null, $like = false)
$this->wheres->$k = $v;
}
} else {
$this->wheres->$data = is_numeric($value ) || is_bool($value) ? $value : new Regex($like ? $value : "^$value\$", "i");
$this->wheres->$data = is_numeric($value) || is_bool($value) ? $value : new Regex($like ? $value : "^$value\$", "i");
}
return $this;
}
Expand Down

0 comments on commit 65fc5f5

Please sign in to comment.