Skip to content

Commit

Permalink
Merge pull request #99 from sheershoff/master
Browse files Browse the repository at this point in the history
Added findAllByPk method to EMongoDocument
  • Loading branch information
Sammaye committed Aug 15, 2013
2 parents ffb208d + 7c29eab commit f0bd09d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions EMongoDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,21 @@ public function findOne($criteria=array(),$fields=array()){
public function findAll($criteria=array(),$fields=array()){
return $this->find ($criteria,$fields);
}

/**
* Finds all records based on $pk
* @param mixed $pk String, MongoID or array of strings or MongoID values (one can mix strings and MongoID in the array)
*/
public function findAllByPk($pk=array(),$fields=array()){
if(is_string($pk)){
return $this->find (array($this->primaryKey() => $this->getPrimaryKey($pk)),$fields);
}else if(is_array($pk)){
foreach($pk as $k=>$v){
$pk[$k] = $this->getPrimaryKey($v);
}
return $this->find (array($this->primaryKey() => array('$in' => $pk)),$fields);
}
}

/**
* Find some records
Expand Down

0 comments on commit f0bd09d

Please sign in to comment.