diff options
author | 2010-02-11 20:17:46 -0700 | |
---|---|---|
committer | 2010-02-11 20:17:46 -0700 | |
commit | 32a7a5f8d8b36ae6acb6e566ff3d371b7a145c4b (patch) | |
tree | f9b8efa8def14998bc8f7a4fed123cc34c98f8db /class.db.mtime.php | |
parent | Zero (diff) | |
download | znurt-org-frontend-32a7a5f8d8b36ae6acb6e566ff3d371b7a145c4b.tar.gz znurt-org-frontend-32a7a5f8d8b36ae6acb6e566ff3d371b7a145c4b.tar.bz2 znurt-org-frontend-32a7a5f8d8b36ae6acb6e566ff3d371b7a145c4b.zip |
initial commit
Diffstat (limited to 'class.db.mtime.php')
-rw-r--r-- | class.db.mtime.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/class.db.mtime.php b/class.db.mtime.php new file mode 100644 index 0000000..e1773fd --- /dev/null +++ b/class.db.mtime.php @@ -0,0 +1,60 @@ +<? + + class DBMtime { + + private $filename; + private $filemtime; + private $mtime; + + function __construct($filename) { + + $db =& MDB2::singleton(); + + $this->filename = $filename; + + if(file_exists($filename)) + $this->filemtime = filemtime($filename); + + $sql = "SELECT mtime FROM mtime WHERE filename = ".$db->quote($this->filename).";"; + + $this->mtime = $db->getOne($sql); + + } + + public function __get($var) { + return $this->$var; + } + + public function __set($var, $value) { + + $db =& MDB2::singleton(); + + if($var == 'mtime') { + + $udate = $db->getOne("SELECT NOW();"); + + if(is_null($this->mtime)) { + + $arr_insert = array( + 'filename' => $this->filename, + 'mtime' => $value, + ); + + $db->autoExecute('mtime', $arr_insert, MDB2_AUTOQUERY_INSERT); + } else { + + $arr_update = array( + 'mtime' => $value, + 'udate' => $udate, + ); + + $db->autoExecute('mtime', $arr_update, MDB2_AUTOQUERY_UPDATE, "filename = ".$db->quote($this->filename)); + } + + } + + } + + } + +?>
\ No newline at end of file |