PDO
在线手册:中文 英文
PHP手册

The PDOStatement class

(No version information available, might only be in SVN)

简介

Represents a prepared statement and, after the statement is executed, an associated result set.

类摘要

PDOStatement implements Traversable {
/* 属性 */
readonly string $queryString;
/* 方法 */
bool bindColumn ( mixed $column , mixed &$param [, int $type [, int $maxlen [, mixed $driverdata ]]] )
bool bindParam ( mixed $parameter , mixed &$variable [, int $data_type = PDO::PARAM_STR [, int $length [, mixed $driver_options ]]] )
bool bindValue ( mixed $parameter , mixed $value [, int $data_type = PDO::PARAM_STR ] )
bool closeCursor ( void )
int columnCount ( void )
bool debugDumpParams ( void )
string errorCode ( void )
array errorInfo ( void )
bool execute ([ array $input_parameters ] )
mixed fetch ([ int $fetch_style [, int $cursor_orientation = PDO::FETCH_ORI_NEXT [, int $cursor_offset = 0 ]]] )
array fetchAll ([ int $fetch_style [, mixed $fetch_argument [, array $ctor_args = array() ]]] )
string fetchColumn ([ int $column_number = 0 ] )
mixed fetchObject ([ string $class_name = "stdClass" [, array $ctor_args ]] )
mixed getAttribute ( int $attribute )
array getColumnMeta ( int $column )
bool nextRowset ( void )
int rowCount ( void )
bool setAttribute ( int $attribute , mixed $value )
bool setFetchMode ( int $mode )
}

属性

queryString

Used query string.

Table of Contents


PDO
在线手册:中文 英文
PHP手册
PHP手册 - N: The PDOStatement class

用户评论:

Dmitri Snytkine (25-Jul-2011 02:17)

It looks like cloning PDOStatement object does not make any sense because while clone($sth) will not generate any errors, the returned object is not a new object but a reference to original PDOStatement object $sth.

rosko at zeta dot org dot au (03-Dec-2009 01:50)

There are many references around for returning a refcursor from a pgSQL function using pg_query. All essentially boil down to executing the following single statement (or some variation of it):

 begin; select yourFunction(params...); fetch all in cursorname; commit;

In PDO, this doesn't work because PDO won't allow multiple statements submitted as a single statement (due to SQL injection detection). Instead, try this or similar:

<?php
$sql
= 'select yourFunction(params...)';
$db = new PDO('pgsql:dbname=yourDBname');
$db->beginTransaction();
$cmd = $db->prepare($sql);
if (
$cmd->execute()) {
  if (
$query = $db->query('fetch all in cursorname')) {
    ...
processing...
   
$query->closeCursor();
   
$cmd->closeCursor();
  }
}
$db->commit();
?>