colly
2017-08-07 78981c784ebe0fda3d1ff20cabe4e21bed2e6549
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
<?php
 
class Model_Base{
 
    public function __construct(){
        $this->db = Mongo_Lite::getInstance();
    }
    /**
     * 根据条件获取列表
     * @param  array   $query  [description]
     * @param  array   $fields [description]
     * @param  array   $sort   [description]
     * @param  integer $limit  [description]
     * @param  integer $skip   [description]
     * @return [type]          [description]
     */
    public function getList($query=array(),$fields=array(),$sort=array(),$limit=0,$skip=0){
        return $this->db->select($this->table, $query, $fields, $sort, $limit, $skip);
    }
 
    /**
     * 根据条件,获取单条数据
     * @param  array  $query  [description]
     * @param  array  $fields [description]
     * @return [type]         [description]
     */
    public function get($query=array(), $fields=array()){
        return $this->db->fetchRow($this->table, $query, $fields);
    }
 
    /**
     * 根据条件获取数量
     * @param  array   $query [description]
     * @param  integer $limit [description]
     * @param  integer $skip  [description]
     * @return [type]         [description]
     */
    public function count($query=array(),$limit=0,$skip=0){
        return $this->db->count($this->table, $query,$limit, $skip);
    }
 
    /**
     * [add description]
     */
    public function add($data){
        return $this->db->insert($this->table, $data);
    }
 
    /**
     * [add description]
     */
    public function save($data){
        return $this->db->insert($this->table, $data);
    }
 
    public function update($data, $query){
        return $this->db->update($this->table, $data, $query);
    }
 
    public function aggregate($params){
        return $this->db->aggregate($this->table, $params);
    }
}