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

Class: WindSqlStatement

Source Location: /db/WindSqlStatement.php

Class WindSqlStatement

Class Overview

sql语句处理类,该类封装了基础的sql处理方法

实现了基础的,数据绑定,参数绑定以及基础查询接口. 通过调用'WindConnection'的'createStatement()'方法,可以获得一个statement对象.

Located in /db/WindSqlStatement.php [line 16]



		
				Author(s):
		
		
		
Information Tags:
Version:  $Id: WindSqlStatement.php 3431 2012-03-21 14:37:51Z yishuo $
Copyright:  ©2003-2103 phpwind.com
License:  http://www.windframework.com

Methods

[ Top ]
Method Summary
WindSqlStatement   __construct()  
WindSqlStatement   bindColumn()   绑定输出结果集的列到PHP变量
WindSqlStatement   bindColumns()   批量绑定输出结果集的列到PHP变量
WindSqlStatement   bindParam()   参数绑定
WindSqlStatement   bindParams()   批量绑定变量
WindSqlStatement   bindValue()   参数绑定
WindSqlStatement   bindValues()   调用bindValue的批量绑定参数
rowCount   execute()   绑定参数,执行SQL语句,并返回影响行数
array   getColumns()   获得需要绑定的结果输出的列值
WindConnection   getConnection()   获得PDO链接对象
array   getOne()   绑定参数,执行SQL语句,并返回一行查询结果
string   getQueryString()   获得查询的预定义语句
PDOStatement   getStatement()   获得PDOStatement对象
string   getValue()   绑定参数,执行SQL语句,并返回查询到的结果集中某一个列的值
void   init()   初始化数据库链接信息
void   lastInsertId()  
WindResultSet   query()   绑定参数,执行SQL语句,并返回查询结果
array   queryAll()   绑定参数,执行SQL语句,并返回查询结果
int|boolean   update()   绑定参数,执行SQL语句,并返回更新影响行数

[ Top ]
Methods
Constructor __construct  [line 48]

  WindSqlStatement __construct( WindConnection $connection, string $query  )

Parameters:
WindConnection   $connection:  WindConnection对象
string   $query:  预定义语句

API Tags:
Access:  public


[ Top ]
bindColumn  [line 163]

  WindSqlStatement bindColumn( mixed $column, [mixed &$param = ''], [int $type = null], [int $maxlen = null], [mixed $driverdata = null]  )

绑定输出结果集的列到PHP变量

Parameters:
mixed   $column:  需要被绑定的字段列表,可以是字段名,也可以是字段的对应的下标
mixed   &$param:  需要被绑定的php变量
int   $type:  参数的数据类型 PDO::PARAM_*
int   $maxlen:  A hint for pre-allocation.
mixed   $driverdata:  Optional parameter(s) for the driver.

API Tags:
See:  PDOStatement::bindColumn()
Access:  public

Information Tags:
Throws:  WindDbException

[ Top ]
bindColumns  [line 188]

  WindSqlStatement bindColumns( array $columns, [array &$param = array()]  )

批量绑定输出结果集的列到PHP变量

Parameters:
array   $columns:  待绑定的列
array   &$param:  需要绑定的php变量

API Tags:
See:  PDOStatement::bindColumn()
Access:  public


[ Top ]
bindParam  [line 65]

  WindSqlStatement bindParam( mixed $parameter, mixed &$variable, [int $dataType = null], [int $length = null], [mixed $driverOptions = null]  )

参数绑定

Parameters:
mixed   $parameter:  预定义语句的待绑定的位置
mixed   &$variable:  绑定的值
int   $dataType:  值的类型(PDO::PARAM_STR/PDO::PARAM_INT...)
int   $length:  绑定值的长度
mixed   $driverOptions: 

API Tags:
See:  PDOStatement::bindParam()
Access:  public

Information Tags:
Throws:  WindDbException

[ Top ]
bindParams  [line 92]

  WindSqlStatement bindParams( &$parameters, array $parameters  )

批量绑定变量

如果是一维数组,则使用key=>value的形式,key代表变量位置,value代表替换的值,而替换值需要的类型则通过该值的类型来判断---不准确 如果是一个二维数组,则允许,key=>array(0=>value, 1=>data_type, 2=>length, 3=>driver_options)的方式来传递变量。

Parameters:
array   $parameters: 
   &$parameters: 

API Tags:
See:  PDOStatement::bindParam()
Access:  public

Information Tags:
Throws:  WindDbException

[ Top ]
bindValue  [line 120]

  WindSqlStatement bindValue( string $parameter, string $value, [int $data_type = null]  )

参数绑定

Parameters:
string   $parameter:  预定义语句的待绑定的位置
string   $value:  绑定的值
int   $data_type:  值的类型

API Tags:
See:  PDOStatement::bindValue()
Access:  public

Information Tags:
Throws:  WindDbException

[ Top ]
bindValues  [line 139]

  WindSqlStatement bindValues( array $values  )

调用bindValue的批量绑定参数

Parameters:
array   $values:  待绑定的参数值

API Tags:
See:  PDOStatement::bindValue()
Access:  public

Information Tags:
Throws:  WindDbException

[ Top ]
execute  [line 277]

  rowCount execute( [array $params = array()], [boolean $rowCount = true]  )

绑定参数,执行SQL语句,并返回影响行数

Parameters:
array   $params:  -- 绑定的参数和bindValues的参数一样
boolean   $rowCount:  是否返回受印象行数

API Tags:
Access:  public


[ Top ]
getColumns  [line 331]

  array getColumns( )

获得需要绑定的结果输出的列值


API Tags:
Access:  public


[ Top ]
getConnection  [line 313]

  WindConnection getConnection( )

获得PDO链接对象


API Tags:
Access:  public


[ Top ]
getOne  [line 257]

  array getOne( [array $params = array()], [int $fetchMode = 0], [int $fetchType = 0]  )

绑定参数,执行SQL语句,并返回一行查询结果

Parameters:
array   $params:  预定义语句中需要绑定的参数
int   $fetchMode:  获得结果集的模式PDO::FETCH_BOTH/PDO::FETCH_ASSOC/PDO::FETCH_NUM
int   $fetchType:  设置结果集的读取方式,PDO::FETCH_ORI_NEXT/PDO::FETCH_ORI_PRE,注意要使用该属性,必须通过setAttribute设置PDO::ATTR_CURSOR=PDO::CURSOR_SCROLL

API Tags:
Access:  public


[ Top ]
getQueryString  [line 304]

  string getQueryString( )

获得查询的预定义语句


API Tags:
Access:  public


[ Top ]
getStatement  [line 322]

  PDOStatement getStatement( )

获得PDOStatement对象


API Tags:
Access:  public


[ Top ]
getValue  [line 243]

  string getValue( [array $params = array()], [int $column = 0]  )

绑定参数,执行SQL语句,并返回查询到的结果集中某一个列的值

Parameters:
array   $params:  预定义语句中需要绑定的参数
int   $column:  列的下标,默认为0即第一列

API Tags:
Access:  public


[ Top ]
init  [line 341]

  void init( )

初始化数据库链接信息


API Tags:
Access:  public

Information Tags:
Throws:  WindDbException

[ Top ]
lastInsertId  [line 266]

  void lastInsertId( [ $name = '']  )

Parameters:
   $name: 

API Tags:
Access:  public


[ Top ]
query  [line 216]

  WindResultSet query( [array $params = array()], [int $fetchMode = 0], [int $fetchType = 0]  )

绑定参数,执行SQL语句,并返回查询结果

Parameters:
array   $params:  预定义语句中需要绑定的参数
int   $fetchMode:  获得结果集的模式PDO::FETCH_BOTH/PDO::FETCH_ASSOC/PDO::FETCH_NUM
int   $fetchType:  设置结果集的读取方式,PDO::FETCH_ORI_NEXT/PDO::FETCH_ORI_PRE,注意要使用该属性,必须通过setAttribute设置PDO::ATTR_CURSOR=PDO::CURSOR_SCROLL

API Tags:
Access:  public


[ Top ]
queryAll  [line 230]

  array queryAll( [array $params = array()], [string $index = ''], [int $fetchMode = 0], [int $fetchType = 0]  )

绑定参数,执行SQL语句,并返回查询结果

Parameters:
array   $params:  预定义语句中需要绑定的参数
string   $index:  返回的数组的下标对应的字段
int   $fetchMode:  获得结果集的模式PDO::FETCH_BOTH/PDO::FETCH_ASSOC/PDO::FETCH_NUM
int   $fetchType:  设置结果集的读取方式,PDO::FETCH_ORI_NEXT/PDO::FETCH_ORI_PRE,注意要使用该属性,必须通过setAttribute设置PDO::ATTR_CURSOR=PDO::CURSOR_SCROLL

API Tags:
Return:  返回处理后的结果
Access:  public


[ Top ]
update  [line 204]

  int|boolean update( [array $params = array()], [boolean $rowCount = false]  )

绑定参数,执行SQL语句,并返回更新影响行数

Parameters:
array   $params:  预定义语句中需要绑定的参数
boolean   $rowCount:  是否返回影响行数

API Tags:
Access:  public

Information Tags:
Throws:  WindDbException

[ Top ]

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