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:
16
dbjson.php
16
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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user