phpjsondb/inc/Class.PHPJSONDB.inc.php
2024-09-02 19:31:43 +02:00

25 lines
813 B
PHP

<?php
class PHPJSONDB {
static function put($db,$table,$item,$data) {
global $phpjsondb_dbpath;
if ( !isset($phpjsondb_dbpath) ) { $phpjsondb_dbpath="./db"; }
if ( !file_exists($phpjsondb_dbpath."/".$db."/".$table."/".md5($item).".data") ) {
@mkdir($phpjsondb_dbpath."/".$db."/".$table,0755,TRUE);
file_put_contents($phpjsondb_dbpath."/".$db."/".$table."/".md5($item).".json",json_encode($data));
}
return TRUE;
}
static function get($db,$table,$item) {
if ( !isset($phpjsondb_dbpath) ) { $phpjsondb_dbpath="./db"; }
global $phpjsondb_dbpath;
if ( file_exists($phpjsondb_dbpath."/".$db."/".$table."/".md5($item).".json") ) {
return json_decode(file_get_contents($phpjsondb_dbpath."/".$db."/".$table."/".md5($item).".json"));
}
return FALSE;
}
}
class PJDB extends PHPJSONDB {
}