Skip to content

Commit

Permalink
Fixed version handling of documents
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammaye committed Oct 8, 2013
1 parent 5c2499b commit f8c6b77
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions EMongoDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ public function equals($record)
* @return NULL|EMongoDocument
*/
public function getLastVersion(){
$c=$this->find()->sort(array($this->versionField() => -1))->limit(1);
$c=$this->find(array($this->primaryKey()=>$this->getPrimaryKey()))->sort(array($this->versionField() => -1))->limit(1);
if($c->count()<=0){
return null;
}else{
Expand All @@ -707,7 +707,7 @@ public function getLastVersion(){
* @return NULL|EMongoDocument
*/
public function getVersion($num){
$c=$this->find(array($this->versionField() => $num))->sort(array($this->versionField() => -1))->limit(1);
$c=$this->find(array($this->primaryKey()=>$this->getPrimaryKey(), $this->versionField() => $num))->sort(array($this->versionField() => -1))->limit(1);
if($c->count()<=0){
return null;
}else{
Expand Down

0 comments on commit f8c6b77

Please sign in to comment.