From 84dbeb45ba59482abf8cc6c20010d1e059798ede Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sat, 5 Mar 2016 10:42:21 +0000 Subject: [PATCH] dbjson : Use the $this->db instead of $data to store the database git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2647 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dbjson.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dbjson.php b/dbjson.php index c03884b..05a5f22 100644 --- a/dbjson.php +++ b/dbjson.php @@ -73,7 +73,7 @@ class dbjson $this->db[$collection]["content"][$uniqueKey] = array_merge ( array ("_id"=>$uniqueKey), $document); - $this->writeDB ($this->db); + $this->writeDB (); $this->lockUN (); return 1; } @@ -97,7 +97,7 @@ class dbjson array ("_id"=>$uniqueKey), $document); } - $this->writeDB ($this->db); + $this->writeDB (); $this->db = null; $this->lockUN (); return count ($documents); @@ -197,7 +197,7 @@ class dbjson $this->db[$collection]["content"][$key])) unset ($this->db[$collection]["content"][$key][$field]); } - $this->writeDB ($this->db); + $this->writeDB (); $this->lockUN (); $this->db = null; return count ($keys); @@ -223,7 +223,7 @@ class dbjson $replace = array_merge ($replace, $document); $this->db[$collection]["content"][$key] = $replace; } - $this->writeDB ($this->db); + $this->writeDB (); $this->lockUN (); $this->db = null; return count ($keys); @@ -245,7 +245,7 @@ class dbjson reset ($keys); $key = key ($keys); unset ($this->db[$collection]["content"][$key]); - $this->writeDB ($this->db); + $this->writeDB (); $this->lockUN (); $this->db = null; return 1; @@ -265,7 +265,7 @@ class dbjson $keys = $this->filter ($collection, $filter); foreach ($keys as $key) unset ($this->db[$collection]["content"][$key]); - $this->writeDB ($this->db); + $this->writeDB (); $this->lockUN (); $this->db = null; return count ($keys); @@ -417,8 +417,8 @@ class dbjson * @param $data array The database to store * @return bool True if the recording is OK, false if there is a problem */ - private function writeDB ($data) + private function writeDB () { - return !! file_put_contents ($this->dbfile, json_encode ($data)); + return !! file_put_contents ($this->dbfile, json_encode ($this->db)); } }