downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

PDOStatement->bindColumn> <PDO::setAttribute
Last updated: Fri, 11 Dec 2009

view this page in

La classe PDOStatement

Introduction

Représente une requête préparée et, une fois exécutée, le jeu de résultats associé.

Synopsis de la classe

PDOStatement
PDOStatement implements Traversable {
/* Propriétés */
readonlystring $queryString;
/* Méthodes */
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 = array() ] )
mixed fetch ([ int $fetch_style = PDO::FETCH_BOTH [, int $cursor_orientation = PDO::FETCH_ORI_NEXT [, int $cursor_offset = 0 ]]] )
array fetchAll ([ int $fetch_style = PDO::FETCH_BOTH [, int $column_index = 0 [, 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 )
}

Propriétés

queryString

chaîne de caractères utilisée pour la requête.

Sommaire



add a note add a note User Contributed Notes
PDOStatement
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();
?>
james dot ellis at gmail dot com
07-Jul-2009 01:25
The query string used in a PDOStatement can be found using the (undocumented) property 'queryString'

<?php
//$stm is a prepared PDOStatement
print $stm->queryString
//example result
//SELECT firstname, lastname FROM user where id = :id
?>

PDOStatement->bindColumn> <PDO::setAttribute
Last updated: Fri, 11 Dec 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites