选择语言 :

Driver_Database_Driver_Mongo
    └ Module_Database_Driver

数据库Mongo驱动

API - Driver_Database_Driver_Mongo

继承自父类的方法和变量
author
呼吸二氧化碳 jonwang@myqee.com
category
Driver
package
Database
subpackage
Mongo
copyright
Copyright © 2008-2013 myqee.com
license
http://www.myqee.com/license.html

$this->connect( $use_connection_type = null)

连接数据库

$use_connection_type 默认不传为自动判断,可传true/false,若传字符串(只支持a-z0-9的字符串),则可以切换到另外一个连接,比如传other,则可以连接到$this->_connection_other_id所对应的ID的连接

参数列表

参数 类型 描述 默认值
$use_connection_type boolean 是否使用主数据库 null

$this->connection( )

获取当前连接

返回值
  • MongoDB

$this->_connect( )


$this->close_connect( )

关闭链接


$this->_select_db( $database )

切换表

参数列表

参数 类型 描述 默认值
$database string Database
返回值
  • void

$this->compile( )

构建SQL语句


$this->set_charset( )


$this->escape( $value )

Sanitize a string by escaping characters that could cause an SQL injection attack.

$value = $db->escape('any string');

参数列表

参数 类型 描述 默认值
$value string Value to quote
返回值
  • string

$this->quote_table( )


$this->quote( $value )

Quote a value for an SQL query.

$db->quote(null); // 'NULL' $db->quote(10); // 10 $db->quote('fred'); // 'fred'

Objects passed to this function will be converted to strings. [Database_Expression] objects will use the value of the expression. [Database_Query] objects will be compiled and converted to a sub-query. All other objects will be converted using the __toString method.

参数列表

参数 类型 描述 默认值
$value mixed Any value to quote
返回值
  • string

$this->query( $options , $as_object = null, $use_connection_type = null)

执行查询

目前支持插入、修改、保存(类似mysql的replace)查询

$use_connection_type 默认不传为自动判断,可传true/false,若传字符串(只支持a-z0-9的字符串),则可以切换到另外一个连接,比如传other,则可以连接到$this->_connection_other_id所对应的ID的连接

参数列表

参数 类型 描述 默认值
$options array $options
$as_object string 是否返回对象 null
$use_connection_type boolean $use_master 是否使用主数据库,不设置则自动判断 null
返回值
  • Database_Driver_Mongo_Result

Database_Driver_Mongo::_compile_set_data( )


Database_Driver_Mongo::_compile_paste_data( )


$this->_compile_conditions( $conditions , $parameters )

Compiles an array of conditions into an SQL partial. Used for WHERE and HAVING.

参数列表

参数 类型 描述 默认值
$conditions object Database instance
$parameters array Condition statements
返回值
  • string

$this->__construct( )


$this->__destruct( )


$this->connection_id( )

获取当前连接的唯一ID

返回值
  • string

$this->transaction( )

获取事务对象

返回值
  • Database_Transaction

$this->last_query( )

最后查询的SQL语句

返回值
  • string

$this->_get_rand_host( $exclude_hosts = array ( ), $type = null)

获取一个随机HOST

参数列表

参数 类型 描述 默认值
$exclude_hosts array 排除的HOST array(0)
$type string 配置类型 null

$this->_get_connection_hash( $hostname , $port , $username )

获取链接唯一hash

参数列表

参数 类型 描述 默认值
$hostname string $hostname
$port int $port
$username string $username
返回值
  • string

Database_Driver::_get_hostname_by_connection_hash( $hash )

根据数据库连接唯一hash获取数据信息

参数列表

参数 类型 描述 默认值
$hash string $has
返回值
  • array array('hostname'=>'','port'=>'','username'=>'')

$this->_change_charset( & $value )

切换编码

参数列表

参数 类型 描述 默认值
$value string $value

$this->_set_connection_type( $use_connection_type )

设置连接类型

$use_connection_type 默认不传为自动判断,可传true/false,若传字符串(只支持a-z0-9的字符串),则可以切换到另外一个连接,比如传other,则可以连接到$this->_connection_other_id所对应的ID的连接

参数列表

参数 类型 描述 默认值
$use_connection_type boolean|string $use_connection_type