PHP Class db_mongo, zys

Author: zqf Mongo数据库驱动 必须配合MongoModel使用
Inheritance: extends db_Db
Show file Open project: qieangel2013/zys

Protected Properties

Property Type Description
$_collection MongoDb Object
$_collectionName dbName
$_cursor collectionName
$_dbName MongoCollection Object
$_mongo
$comparison MongoCursor Object

Public Methods

Method Description
__construct ( array $config = '' ) 架构函数 读取数据库配置信息
clear ( array $options = [] ) : false | integer 清空记录
close ( ) 关闭数据库
command ( array $command = [] ) : array 执行命令
connect ( $config = '', $linkNum ) 连接数据库方法
count ( array $options = [] ) : iterator 统计记录数
delete ( array $options = [] ) : false | integer 删除记录
error ( ) : string 数据库错误信息
execute ( string $code, array $args = [] ) : mixed 执行语句
find ( array $options = [] ) : array 查找某个记录
free ( ) 释放查询结果
getFields ( $collection = '' ) : array 取得数据表的字段信息
getTables ( ) 取得当前数据库的collection信息
group ( $keys, $initial, $reduce, $options = [] )
insert ( mixed $data, array $options = [], boolean $replace = false ) : false | integer 插入记录
insertAll ( array $dataList, array $options = [] ) : boolean 插入多条记录
mongo_next_id ( string $pk ) : integer 生成下一条记录ID 用于自增非MongoId主键
parseField ( mixed $fields ) : array field分析
parseWhere ( mixed $where ) : array where分析
select ( array $options = [] ) : iterator 查找记录
switchCollection ( string $collection, string $db = '', boolean $master = true ) : void 切换当前操作的Db和Collection
update ( mixed $data, array $options ) : boolean 更新记录

Protected Methods

Method Description
parseLimit ( mixed $limit ) : array limit分析
parseOrder ( mixed $order ) : array order分析
parseSet ( array $data ) : string set分析
parseThinkWhere ( string $key, mixed $val ) : string 特殊条件分析
parseWhereItem ( string $key, mixed $val ) : array where子单元分析

Method Details

__construct() public method

架构函数 读取数据库配置信息
public __construct ( array $config = '' )
$config array 数据库配置数组

clear() public method

清空记录
public clear ( array $options = [] ) : false | integer
$options array 表达式
return false | integer | integer

close() public method

关闭数据库
public close ( )

command() public method

执行命令
public command ( array $command = [] ) : array
$command array 指令
return array

connect() public method

连接数据库方法
public connect ( $config = '', $linkNum )

count() public method

统计记录数
public count ( array $options = [] ) : iterator
$options array 表达式
return iterator

delete() public method

删除记录
public delete ( array $options = [] ) : false | integer
$options array 表达式
return false | integer | integer

error() public method

数据库错误信息
public error ( ) : string
return string

execute() public method

执行语句
public execute ( string $code, array $args = [] ) : mixed
$code string sql指令
$args array 参数
return mixed

find() public method

查找某个记录
public find ( array $options = [] ) : array
$options array 表达式
return array

free() public method

释放查询结果
public free ( )

getFields() public method

取得数据表的字段信息
public getFields ( $collection = '' ) : array
return array

getTables() public method

取得当前数据库的collection信息
public getTables ( )

group() public method

public group ( $keys, $initial, $reduce, $options = [] )

insert() public method

插入记录
public insert ( mixed $data, array $options = [], boolean $replace = false ) : false | integer
$data mixed 数据
$options array 参数表达式
$replace boolean 是否replace
return false | integer | integer

insertAll() public method

插入多条记录
public insertAll ( array $dataList, array $options = [] ) : boolean
$dataList array 数据
$options array 参数表达式
return boolean

mongo_next_id() public method

生成下一条记录ID 用于自增非MongoId主键
public mongo_next_id ( string $pk ) : integer
$pk string 主键名
return integer

parseField() public method

field分析
public parseField ( mixed $fields ) : array
$fields mixed
return array

parseLimit() protected method

limit分析
protected parseLimit ( mixed $limit ) : array
$limit mixed
return array

parseOrder() protected method

order分析
protected parseOrder ( mixed $order ) : array
$order mixed
return array

parseSet() protected method

set分析
protected parseSet ( array $data ) : string
$data array
return string

parseThinkWhere() protected method

特殊条件分析
protected parseThinkWhere ( string $key, mixed $val ) : string
$key string
$val mixed
return string

parseWhere() public method

where分析
public parseWhere ( mixed $where ) : array
$where mixed
return array

parseWhereItem() protected method

where子单元分析
protected parseWhereItem ( string $key, mixed $val ) : array
$key string
$val mixed
return array

select() public method

查找记录
public select ( array $options = [] ) : iterator
$options array 表达式
return iterator

switchCollection() public method

切换当前操作的Db和Collection
public switchCollection ( string $collection, string $db = '', boolean $master = true ) : void
$collection string collection
$db string db
$master boolean 是否主服务器
return void

update() public method

更新记录
public update ( mixed $data, array $options ) : boolean
$data mixed 数据
$options array 表达式
return boolean

Property Details

$_collection protected property

MongoDb Object
protected $_collection

$_collectionName protected property

dbName
protected $_collectionName

$_cursor protected property

collectionName
protected $_cursor

$_dbName protected property

MongoCollection Object
protected $_dbName

$_mongo protected property

protected $_mongo

$comparison protected property

MongoCursor Object
protected $comparison