Re: What's the number scheme for 'colno' for Select call in PDO driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Sanjeev Kumar wrote:
> Hi,
>
> In the implemetation of Pdo-driver (extension) , what's the Sequence/Index
> scheme for parameter:  'colno'  ?
>
> This param 'colno' is input in driver calls (of PDO statement) :
>
> int SKEL_stmt_describe_col(pdo_stmt_t *stmt, int colno TSRMLS_DC)
>
> int SKEL_stmt_get_col_data(pdo_stmt_t *stmt, int colno, ...)
>
>
> e.g If the script has cmds:
> Insert into Table test1(col1 int, col2 string, col3 real)
>   SELECT  col2,col3 from test1;
>
> The driver would which values for colno ?
>
> -sanjeev
>

In ext/pdo/php_pdo_driver.h:

  /* queries information about the type of a column, by index (0 based).
   * Driver should populate stmt->columns[colno] with appropriate info */
  typedef int (*pdo_stmt_describe_col_func)(pdo_stmt_t *stmt, int colno TSRMLS_DC);

Colno is a 0 based relative to the columns used in the query.

A working example is oci_stmt_describe() in
ext/pdo_oci/oci_statement.c.  This callback is assigned to the
"describer" field of oci_stmt_methods at the bottom of the same file.

The callback gets called from pdo_stmt_describe_columns() in
ext/pdo/pdo_stmt.c.

Similarly, see oci_stmt_get_col() for the second skeleton function you
mention.

Chris

--
Blog: http://blogs.oracle.com/opal
Twitter:  http://twitter.com/ghrd

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux