选择语言 :

Driver_Database_Driver_Postgre
    └ Module_Database_Driver

数据库Postgre返回类

API - Driver_Database_Driver_Postgre

继承自父类的方法和变量
author
呼吸二氧化碳 jonwang@myqee.com
category
Driver
package
Database
subpackage
Postgre
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( )

获取当前连接

返回值
  • pg_connect

$this->_connect( )


$this->_check_connect( )

检查连接是否可用

防止因长时间不链接而导致连接丢失的问题 server has gone away


$this->close_connect( )

关闭链接


$this->compile( )

构建SQL语句


$this->set_charset( $charset )

设置编码

参数列表

参数 类型 描述 默认值
$charset string $charset
返回值
  • void|boolean

$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->query( $sql , $as_object = null, $use_connection_type = null)

查询

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

参数列表

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

$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->quote_table( $value , $auto_as_table = false)

Quote a database table name and adds the table prefix if needed.

$table = $db->quote_table($table);

参数列表

参数 类型 描述 默认值
$value mixed Table name or array(table, alias)
$auto_as_table unknown bool false
返回值
  • string

$this->create_database( $database , $charset = null, $collate = null)

创建一个数据库

参数列表

参数 类型 描述 默认值
$database string $database
$charset string 编码,不传则使用数据库连接配置相同到编码 null
$collate string 整理格式 null
返回值
  • boolean

$this->_insert_id( )

获取最后插入的ID

返回值
  • int

$this->_quote_identifier( )


$this->_compile_selete( )


$this->_compile_insert( )

Compile the SQL query and return it.

返回值
  • string

$this->_compile_update( )


$this->_compile_delete( )


$this->_compile_order_by( $columns )

Compiles an array of ORDER BY statements into an SQL partial.

参数列表

参数 类型 描述 默认值
$columns object Database instance
返回值
  • string

$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->_compile_join( $joins )

Compiles an array of JOIN statements into an SQL partial.

参数列表

参数 类型 描述 默认值
$joins object Database instance
返回值
  • string

$this->_compile_join_on( )


$this->_compile_set( $values , $parameters )

Compiles an array of set values into an SQL partial. Used for UPDATE.

参数列表

参数 类型 描述 默认值
$values object Database instance
$parameters array Updated values
返回值
  • string

$this->_init_as_table( )

初始化所有的as_table


$this->_do_init_as_table( )


$this->_get_dsn( )


$this->format_select_adv( )

格式化高级查询参数到select里


$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