选择语言 :

Module_Database_Driver

数据库驱动核心类

API - Module_Database_Driver

author
呼吸二氧化碳 jonwang@myqee.com
category
MyQEE
package
Module
subpackage
Database
copyright
Copyright © 2008-2013 myqee.com
license
http://www.myqee.com/license.html

$this->__construct( )


$this->__destruct( )


$this->compile( )

构建SQL语句


$this->query( $sql , $as_object = null, $use_master = null)

查询

参数列表

参数 类型 描述 默认值
$sql string 查询语句
$as_object string 是否返回对象 null
$use_master boolean 是否使用主数据库,不设置则自动判断 null
返回值
  • Database_Driver_MySQLI_Result

$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->close_connect( )

关闭链接


$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->connection( )

获取当前连接

返回值
  • mysqli
  • mysql

$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