/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui

« back to all changes in this revision

Viewing changes to classes/cache/cachedata.php

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
class CACHEData implements Iterator {
 
3
 var $cache;
 
4
 var $query;
 
5
 
 
6
 var $res;
 
7
 var $key, $row;
 
8
 
 
9
 
 
10
 function __construct(CACHEDB &$cache, $table, $from, $to) {
 
11
    $this->cache = &$cache;
 
12
//    $this->query = "SELECT * FROM `$table` WHERE `time` BETWEEN FROM_UNIXTIME($from) AND FROM_UNIXTIME($to) ORDER BY `time` ASC";
 
13
    $this->query = "SELECT * FROM `$table` WHERE ((`time` >= FROM_UNIXTIME($from)) AND (`time` < FROM_UNIXTIME($to))) ORDER BY `time` ASC";
 
14
 }
 
15
 
 
16
 
 
17
 function rewind() {
 
18
    $this->res = mysql_query($this->query, $this->cache->dbh);
 
19
    if (!$this->res)
 
20
        throw new ADEIException(translate("Select request to CACHE is failed [%s]", $this->query));
 
21
    $this->next();
 
22
 }
 
23
 
 
24
 function current() {
 
25
    return $this->row;
 
26
 }
 
27
 
 
28
 function key() {
 
29
    return $this->key;
 
30
 }
 
31
 
 
32
 function next() {
 
33
    $this->row = mysql_fetch_row($this->res);
 
34
    if ($this->row) $this->key = strtotime($this->row[0]);
 
35
    else {
 
36
        $this->key = 0;
 
37
        mysql_free_result($this->res);
 
38
    }
 
39
 }
 
40
 
 
41
 function valid() {
 
42
    return $this->row?true:false;
 
43
 }
 
44
}
 
45
?>
 
 
b'\\ No newline at end of file'