phpDocumentor db
[ class tree: db ] [ index: db ] [ all elements ]

Class: WindConnection

Source Location: /db/WindConnection.php

Class WindConnection

Class Overview

数据库链接,提供了数据库连接服务,以及基本的数据操作方法.

提供了基本的数据连接服务,使用例子如下:

  1.  $connection new WindConnection('mysql:host=localhost;dbname=test''root''root');
  2.  $stm $connection->createStatement('SELECT * FROM {members} WHERE uid<=:uid'true);
  3.  $stm->queryAll();
  4.  //组件配置实用实例:
  5.  'db' => array(
  6.  'path' => 'WIND:db.WindConnection',
  7.  'scope' => 'singleton',
  8.  'config' => array(
  9.  'resource' => 'db_config.php',
  10.  ),),
  11.  //db_config 配置内容:
  12.  array(
  13.  'dsn' => 'mysql:host=localhost;dbname=test',
  14.  'user' => 'root',
  15.  'pwd' => 'root',
  16.  'charset' => 'utf8')

Located in /db/WindConnection.php [line 33]

WindModule
   |
   --WindConnection
Author(s): Information Tags:
Version:  $Id: WindConnection.php 3244 2011-12-07 10:58:12Z yishuo $
Copyright:  ©2003-2103 phpwind.com
License:  http://www.windframework.com

Properties

Methods

[ Top ]
Descendants
Child Class Description
WindConnectionManager 数据库链接管理

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From WindModule

WindModule::$_config
WindModule::$_proxy
WindModule::$_typeValidation

Inherited From WindModule

WindModule::getConfig()
根据配置名取得相应的配置
WindModule::getRequest()
返回当前应用的WindHttpRequest对象
WindModule::getResponse()
返回当前应用的WindHttpResponse对象
WindModule::getSystemFactory()
返回当前应用的WindFactory对象
WindModule::setConfig()
设置类配置
WindModule::setDelayAttributes()
设置延迟加载类属性相关组件配置信息
WindModule::toArray()
返回该对象的数组类型
WindModule::writeTableCloneProperty()
类对象clone白名单
WindModule::__call()
重载了魔术方法__call
WindModule::__clone()
重载魔术方法__clone
WindModule::__get()
重载了魔术方法__get
WindModule::__set()
重载了魔术方法__set

[ Top ]
Property Summary
array   $_attributes   属性值
string   $_charset   数据连接编码方式
PDO   $_dbHandle   数据连接句柄
string   $_driverName   驱动名
string   $_dsn   链接字符串,携带数据驱动类型,主机信息,库名等
string   $_pwd   数据密码
string   $_tablePrefix   数据表前缀
string   $_user   用户名

[ Top ]
Method Summary
WindConnection   __construct()  
void   close()   关闭数据库连接
WindSqlStatement   createStatement()   接受一条sql语句,并返回sqlStatement对象
boolean   createTable()   创建表,返回是否创建成功
int   execute()   执行一条sql语句 同时返回影响行数
string   getAttribute()   获得链接相关属性设置
AbstractWindPdoAdapter   getDbHandle()   返回数据库链接对象
string   getDriverName()   返回DB驱动类型
string   getTablePrefix()   获得表前缀
void   init()   初始化DB句柄
int   lastInsertId()   返回最后一条插入的数据值,当传一个'name'给该方法,则返回'name'对应的列值
void   parseQueryString()   解析当前查询语句,并返回解析后结果
WindResultSet   query()   执行一条查询同时返回结果集
string   quote()   sql元数据安全过滤,并返回过滤后值
string   quoteArray()   过滤数组变量,将数组变量转换为字符串,并用逗号分隔每个数组元素支持多维数组
string   quoteMultiArray()   过滤二维数组将数组变量转换为多组的sql字符串
void   setAttribute()   设置链接相关属性
void   setConfig()   (non-PHPdoc)
void   setTablePrefix()   设置表前缀
void   sqlMetadata()   过滤SQL元数据,数据库对象(如表名字,字段等)
string   sqlSingle()   过滤数组值并返回(insert/update)sql语句形式
void   _initConfig()   根据配置信息,初始化当前连接对象

[ Top ]
Properties
array   $_attributes = array() [line 76]

属性值

API Tags:
Access:  protected


[ Top ]
string   $_charset [line 70]

数据连接编码方式

API Tags:
Access:  protected


[ Top ]
PDO   $_dbHandle = null [line 82]

数据连接句柄

API Tags:
Access:  protected


[ Top ]
string   $_driverName [line 46]

驱动名

API Tags:
Access:  protected


[ Top ]
string   $_dsn [line 40]

链接字符串,携带数据驱动类型,主机信息,库名等

  1. mysql:host=localhost;dbname=test

API Tags:
Access:  protected


[ Top ]
string   $_pwd [line 58]

数据密码

API Tags:
Access:  protected


[ Top ]
string   $_tablePrefix [line 64]

数据表前缀

API Tags:
Access:  protected


[ Top ]
string   $_user [line 52]

用户名

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 89]

  WindConnection __construct( [string $dsn = ''], [string $username = ''], [string $password = '']  )

Parameters:
string   $dsn: 
string   $username: 
string   $password: 

API Tags:
Access:  public


[ Top ]
close  [line 279]

  void close( )

关闭数据库连接


API Tags:
Access:  public


[ Top ]
createStatement  [line 101]

  WindSqlStatement createStatement( [string $sql = null]  )

接受一条sql语句,并返回sqlStatement对象

Parameters:
string   $sql:  sql语句

API Tags:
Access:  public


Redefined in descendants as:

[ Top ]
createTable  [line 257]

  boolean createTable( string $tableName, array $values, [boolean $replace = false]  )

创建表,返回是否创建成功

创建表并返回是否创建成功'$values'为字段信息.该方法的具体实现根据数据库的链接类型不同有所不同.

Parameters:
string   $tableName:  表名称
array   $values:  字段值信息
boolean   $replace:  是否覆盖

API Tags:
See:  AbstractWindPdoAdapter::createTable()
Access:  public


[ Top ]
execute  [line 164]

  int execute( string $sql  )

执行一条sql语句 同时返回影响行数

Parameters:
string   $sql:  sql语句

API Tags:
Access:  public


[ Top ]
getAttribute  [line 121]

  string getAttribute( string $attribute  )

获得链接相关属性设置

Parameters:
string   $attribute: 

API Tags:
Access:  public


[ Top ]
getDbHandle  [line 110]

  AbstractWindPdoAdapter getDbHandle( )

返回数据库链接对象


API Tags:
Access:  public


Redefined in descendants as:

[ Top ]
getDriverName  [line 148]

  string getDriverName( )

返回DB驱动类型


API Tags:
Access:  public


[ Top ]
getTablePrefix  [line 348]

  string getTablePrefix( )

获得表前缀


API Tags:
Access:  public


[ Top ]
init  [line 289]

  void init( )

初始化DB句柄


API Tags:
Access:  public

Information Tags:
Throws:  WindDbException

Redefined in descendants as:

[ Top ]
lastInsertId  [line 267]

  int lastInsertId( [string $name = '']  )

返回最后一条插入的数据值,当传一个'name'给该方法,则返回'name'对应的列值

Parameters:
string   $name:  默认为空字符串

API Tags:
Access:  public


[ Top ]
parseQueryString  [line 335]

  void parseQueryString( string $sql  )

解析当前查询语句,并返回解析后结果

Parameters:
string   $sql: 

API Tags:
Access:  protected


Redefined in descendants as:

[ Top ]
query  [line 185]

  WindResultSet query( string $sql  )

执行一条查询同时返回结果集

Parameters:
string   $sql:  sql语句

API Tags:
Access:  public


[ Top ]
quote  [line 230]

  string quote( string $string  )

sql元数据安全过滤,并返回过滤后值

Parameters:
string   $string: 

API Tags:
Access:  public


[ Top ]
quoteArray  [line 210]

  string quoteArray( array $array  )

过滤数组变量,将数组变量转换为字符串,并用逗号分隔每个数组元素支持多维数组

Parameters:
array   $array: 

API Tags:
Access:  public


[ Top ]
quoteMultiArray  [line 220]

  string quoteMultiArray( array $array  )

过滤二维数组将数组变量转换为多组的sql字符串

Parameters:
array   $array: 

API Tags:
Access:  public


[ Top ]
setAttribute  [line 135]

  void setAttribute( string $attribute, [string $value = null]  )

设置链接相关属性

Parameters:
string   $attribute: 
string   $value:  默认值为null

API Tags:
Access:  public


[ Top ]
setConfig  [line 311]

  void setConfig( $config  )

(non-PHPdoc)

Parameters:
   $config: 

API Tags:
See:  WindModule::setConfig()
Access:  public


Redefinition of:
WindModule::setConfig()
设置类配置

[ Top ]
setTablePrefix  [line 357]

  void setTablePrefix( string $tablePrefix  )

设置表前缀

Parameters:
string   $tablePrefix: 

API Tags:
Access:  public


[ Top ]
sqlMetadata  [line 200]

  void sqlMetadata( string $data  )

过滤SQL元数据,数据库对象(如表名字,字段等)

Parameters:
string   $data: 

API Tags:
Access:  public

Information Tags:
Throws:  WindDbException

[ Top ]
sqlSingle  [line 243]

  string sqlSingle( array $array  )

过滤数组值并返回(insert/update)sql语句形式

该方法接收一个数组变量,进行安全过滤,并返回组装单条 key=value 形式的SQL查询语句值 (适用于insert/update value值组装). 该方法的具体实现根据数据库的链接类型不同有所不同.

Parameters:
array   $array: 

API Tags:
See:  AbstractWindPdoAdapter::sqlSingle()
Access:  public


[ Top ]
_initConfig  [line 322]

  void _initConfig( [array $config = array()]  )

根据配置信息,初始化当前连接对象

Parameters:
array   $config:  连接配置,默认为空数组

API Tags:
Access:  protected


Redefined in descendants as:

[ Top ]

Documentation generated on Fri, 30 Mar 2012 11:43:29 +0800 by phpDocumentor 1.4.4