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
|
Method Summary
rowCount |
execute() |
绑定参数,执行SQL语句,并返回影响行数 |
array |
getOne() |
绑定参数,执行SQL语句,并返回一行查询结果 |
string |
getValue() |
绑定参数,执行SQL语句,并返回查询到的结果集中某一个列的值 |
int|boolean |
update() |
绑定参数,执行SQL语句,并返回更新影响行数 |
Methods
WindSqlStatement __construct(
WindConnection
$connection, string
$query
)
|
|
Parameters:
API Tags:
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:
批量绑定输出结果集的列到PHP变量
Parameters:
array |
$columns: |
待绑定的列 |
array |
&$param: |
需要绑定的php变量 |
API Tags:
See: | PDOStatement::bindColumn() |
Access: | public |
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:
批量绑定变量
如果是一维数组,则使用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:
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:
调用bindValue的批量绑定参数
Parameters:
API Tags:
See: | PDOStatement::bindValue() |
Access: | public |
Information Tags:
rowCount execute(
[array
$params = array()], [boolean
$rowCount = true]
)
|
|
绑定参数,执行SQL语句,并返回影响行数
Parameters:
array |
$params: |
-- 绑定的参数和bindValues的参数一样 |
boolean |
$rowCount: |
是否返回受印象行数 |
API Tags:
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:
PDOStatement getStatement(
)
|
|
获得PDOStatement对象
API Tags:
string getValue(
[array
$params = array()], [int
$column = 0]
)
|
|
绑定参数,执行SQL语句,并返回查询到的结果集中某一个列的值
Parameters:
array |
$params: |
预定义语句中需要绑定的参数 |
int |
$column: |
列的下标,默认为0即第一列 |
API Tags:
初始化数据库链接信息
API Tags:
Information Tags:
void lastInsertId(
[
$name = '']
)
|
|
Parameters:
API Tags:
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:
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 |
int|boolean update(
[array
$params = array()], [boolean
$rowCount = false]
)
|
|
绑定参数,执行SQL语句,并返回更新影响行数
Parameters:
array |
$params: |
预定义语句中需要绑定的参数 |
boolean |
$rowCount: |
是否返回影响行数 |
API Tags:
Information Tags:
|
|