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
This commit is contained in:
2016-03-05 10:42:21 +00:00
parent 3dbcb5298e
commit 84dbeb45ba

View File

@@ -73,7 +73,7 @@ class dbjson
$this->db[$collection]["content"][$uniqueKey] = array_merge ( $this->db[$collection]["content"][$uniqueKey] = array_merge (
array ("_id"=>$uniqueKey), array ("_id"=>$uniqueKey),
$document); $document);
$this->writeDB ($this->db); $this->writeDB ();
$this->lockUN (); $this->lockUN ();
return 1; return 1;
} }
@@ -97,7 +97,7 @@ class dbjson
array ("_id"=>$uniqueKey), array ("_id"=>$uniqueKey),
$document); $document);
} }
$this->writeDB ($this->db); $this->writeDB ();
$this->db = null; $this->db = null;
$this->lockUN (); $this->lockUN ();
return count ($documents); return count ($documents);
@@ -197,7 +197,7 @@ class dbjson
$this->db[$collection]["content"][$key])) $this->db[$collection]["content"][$key]))
unset ($this->db[$collection]["content"][$key][$field]); unset ($this->db[$collection]["content"][$key][$field]);
} }
$this->writeDB ($this->db); $this->writeDB ();
$this->lockUN (); $this->lockUN ();
$this->db = null; $this->db = null;
return count ($keys); return count ($keys);
@@ -223,7 +223,7 @@ class dbjson
$replace = array_merge ($replace, $document); $replace = array_merge ($replace, $document);
$this->db[$collection]["content"][$key] = $replace; $this->db[$collection]["content"][$key] = $replace;
} }
$this->writeDB ($this->db); $this->writeDB ();
$this->lockUN (); $this->lockUN ();
$this->db = null; $this->db = null;
return count ($keys); return count ($keys);
@@ -245,7 +245,7 @@ class dbjson
reset ($keys); reset ($keys);
$key = key ($keys); $key = key ($keys);
unset ($this->db[$collection]["content"][$key]); unset ($this->db[$collection]["content"][$key]);
$this->writeDB ($this->db); $this->writeDB ();
$this->lockUN (); $this->lockUN ();
$this->db = null; $this->db = null;
return 1; return 1;
@@ -265,7 +265,7 @@ class dbjson
$keys = $this->filter ($collection, $filter); $keys = $this->filter ($collection, $filter);
foreach ($keys as $key) foreach ($keys as $key)
unset ($this->db[$collection]["content"][$key]); unset ($this->db[$collection]["content"][$key]);
$this->writeDB ($this->db); $this->writeDB ();
$this->lockUN (); $this->lockUN ();
$this->db = null; $this->db = null;
return count ($keys); return count ($keys);
@@ -417,8 +417,8 @@ class dbjson
* @param $data array The database to store * @param $data array The database to store
* @return bool True if the recording is OK, false if there is a problem * @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));
} }
} }