<?php
|
|
class MongoModel extends MongoDb{
|
|
private $_instance;
|
|
public function __construct(){
|
$this->db = MongoDb::getInstance();
|
}
|
|
public static function getInstance(){
|
if(!(self::$_instance instanceof self)){
|
self::$_instance = new sefl();
|
}
|
return self::$_instance;
|
}
|
|
/**
|
* 根据条件获取列表
|
* @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);
|
}
|
|
public function update($data, $query){
|
return $this->db->update($this->table, $data, $query);
|
}
|
|
}
|