Skip to content

Commit

Permalink
add delete_batch function
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Arnodo committed May 31, 2012
1 parent 69721d4 commit 6a2dc01
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions libraries/cimongo/Cimongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public function update($collection = "", $data = array(), $options = array()){
*
* @since v1.0.0
*/
public function update_batch($collection = "", $data = array(), $options = array()){
public function update_batch($collection = "", $data = array()){
return $this->update($collection, $data , array('multiple' => TRUE));
}

Expand All @@ -439,12 +439,13 @@ public function update_batch($collection = "", $data = array(), $options = array
*
* @since v1.0.0
*/
public function delete($collection = ""){
public function delete($collection = "", $options = array()){
if (empty($collection)){
show_error("No Mongo collection selected to delete from", 500);
}
try{
$this->db->{$collection}->remove($this->wheres, array("safe" => $this->query_safety));
$options = array_merge(array("safe" => $this->query_safety),$options);
$this->db->{$collection}->remove($this->wheres, $options);
$this->_clear();
return TRUE;
}catch (MongoCursorException $e){
Expand All @@ -454,6 +455,16 @@ public function delete($collection = ""){
}

}

/**
*
* Delete more than one document
*
* @since v1.2.0
*/
public function delete_batch($collection = "", $options = array()){
return $this->delete($collection , array('justOne' => FALSE));
}

/**
*
Expand Down

0 comments on commit 6a2dc01

Please sign in to comment.