From 2f2f585271e7bc969132196c69b394cc06d3f0db Mon Sep 17 00:00:00 2001 From: black lotus Date: Tue, 7 Oct 2014 09:59:48 +0700 Subject: [PATCH] update update support for PHP 5.6 http://php.net/manual/en/book.mongo.php --- libraries/cimongo/Cimongo.php | 13 +++++-------- libraries/cimongo/Cimongo_base.php | 2 +- libraries/cimongo/Cimongo_cursor.php | 0 libraries/cimongo/Cimongo_extras.php | 0 4 files changed, 6 insertions(+), 9 deletions(-) mode change 100644 => 100755 libraries/cimongo/Cimongo.php mode change 100644 => 100755 libraries/cimongo/Cimongo_base.php mode change 100644 => 100755 libraries/cimongo/Cimongo_cursor.php mode change 100644 => 100755 libraries/cimongo/Cimongo_extras.php diff --git a/libraries/cimongo/Cimongo.php b/libraries/cimongo/Cimongo.php old mode 100644 new mode 100755 index c54a00a..6e4023b --- a/libraries/cimongo/Cimongo.php +++ b/libraries/cimongo/Cimongo.php @@ -1,7 +1,4 @@ -_inserted_id = FALSE; try { - $query = $this->db->selectCollection($collection)->insert($insert, array("safe" => $this->query_safety)); + $query = $this->db->selectCollection($collection)->insert($insert, array("w" => $this->query_safety)); if (isset($insert['_id'])) { $this->_inserted_id = $insert['_id']; return TRUE; @@ -362,7 +359,7 @@ public function insert_batch($collection = "", $insert = array()) { show_error("Nothing to insert into Mongo collection or insert is not an array", 500); } try { - $query = $this->db->selectCollection($collection)->batchInsert($insert, array("safe" => $this->query_safety)); + $query = $this->db->selectCollection($collection)->batchInsert($insert, array("w" => $this->query_safety)); if (is_array($query)) { return $query["err"] === NULL; } else { @@ -412,7 +409,7 @@ public function update($collection = "", $data = array(), $options = array()) { show_error("Nothing to update in Mongo collection or update is not an array", 500); } try { - $options = array_merge(array("safe" => $this->query_safety, 'multiple' => FALSE), $options); + $options = array_merge(array("w" => $this->query_safety, 'multiple' => FALSE), $options); $this->db->selectCollection($collection)->update($this->wheres, $this->updates, $options); $this->_clear(); return TRUE; @@ -446,7 +443,7 @@ public function delete($collection = "", $options = array()) { show_error("No Mongo collection selected to delete from", 500); } try { - $options = array_merge(array("safe" => $this->query_safety), $options); + $options = array_merge(array("w" => $this->query_safety), $options); $this->db->selectCollection($collection)->remove($this->wheres, $options); $this->_clear(); return TRUE; diff --git a/libraries/cimongo/Cimongo_base.php b/libraries/cimongo/Cimongo_base.php old mode 100644 new mode 100755 index 1ce2da4..432971f --- a/libraries/cimongo/Cimongo_base.php +++ b/libraries/cimongo/Cimongo_base.php @@ -128,7 +128,7 @@ public function drop_collection($db = "", $col = ""){ private function connect(){ $options = array(); try{ - $this->connection = new Mongo($this->connection_string, $options); + $this->connection = new MongoClient($this->connection_string, $options); $this->db = $this->connection->{$this->dbname}; return $this; }catch (MongoConnectionException $e){ diff --git a/libraries/cimongo/Cimongo_cursor.php b/libraries/cimongo/Cimongo_cursor.php old mode 100644 new mode 100755 diff --git a/libraries/cimongo/Cimongo_extras.php b/libraries/cimongo/Cimongo_extras.php old mode 100644 new mode 100755