colly_wyx
2018-04-27 74adf3a72663f151dc2c1b87ecb4ea4b0e080a50
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
61
62
63
64
<?php
/**
 * PhalApi_ModelQuery 查询对象(值对象)
 *
 * - 我们强烈建议应将此继承类的实例当作值对象处理,虽然我们提供了便利的结构化获取
 * - 如需要拷贝值对象,可以结合使用构造函数和toArray()
 * 
 * @package     PhalApi\Model
 * @license     http://www.phalapi.net/license GPL 协议
 * @link        http://www.phalapi.net/
 * @author      dogstar <chanzonghuang@gmail.com> 2015-02-22
 */
 
class PhalApi_ModelQuery {
 
    /**
     * @var boolean $readCache 是否读取缓存
     */
    public $readCache = true;
 
    /**
     * @var boolean $writeCache 是否写入缓存
     */
    public $writeCache = true;
 
    /**
     * @var string/int ID
     */
    public $id;
 
    /**
     * @var int $timestamp 时间戳
     */
    public $timestamp;
 
    public function __construct($queryArr = array()) {
        $this->timestamp = $_SERVER['REQUEST_TIME'];
 
        if (DI()->debug) {
            $this->readCache = FALSE;
            $this->writeCache = FALSE;
        }
 
        foreach ($queryArr as $key => $value) {
            $this->$key = $value;
        }
    }
 
    public function __set($name, $value) {
        $this->$name = $value;
    }
 
    public function __get($name) {
        if (isset($this->$name)) {
            return $this->$name;
        }
 
        return NULL;
    }
 
    public function toArray() {
        return get_object_vars($this);
    }
}