blob: e1773fd56a562f807224de782e42340a3b269184 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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));
}
}
}
}
?>
|