Hi,

the following sourcecode:

<?php
  $dbh= new PDO('mysql:host='.$argv[1], $argv[2], $argv[3]); 

  $stmt= $dbh->prepare('select * from entries where id = :id');
  $stmt->bindParam(':id', $argv[4]);
  if (!$stmt->execute()) {
    var_dump($dbh->errorInfo());
    exit;
  }

  for ($i= 0, $s= $stmt->columnCount(); $i < $s; $i++) {
    echo $i, ':: '; var_dump($stmt->getColumnMeta($i));
  }
?>

will print out:

1:: bool(false)
2:: bool(false)
3:: bool(false)
4:: bool(false)
5:: bool(false)
6:: bool(false)
7:: bool(false)
8:: bool(false)
9:: bool(false)
10:: bool(false)
11:: bool(false)
12:: bool(false)
13:: bool(false)
14:: bool(false)

with no indication what went wrong. 

Actually, nothing went wrong, ext/pdo_mysql/mysql_statement.c just
contains a bogus check (there doesn't need to be any current result data
just to fetch result metadata).

This fixes it:

Index: ext/pdo_mysql/mysql_statement.c
===================================================================
RCS file: /repository/php-src/ext/pdo_mysql/mysql_statement.c,v
retrieving revision 1.14
diff -u -r1.14 mysql_statement.c
--- ext/pdo_mysql/mysql_statement.c     13 Feb 2005 00:48:00 -0000
1.14
+++ ext/pdo_mysql/mysql_statement.c     19 Feb 2005 17:05:10 -0000
@@ -191,10 +191,10 @@
        zval *flags;
        char *str;
        
-       if(S->current_data == NULL || !S->result) {
+       if (!S->result) {
                return FAILURE;
        }
-       if(colno >= mysql_num_fields(S->result)) {
+       if (colno >= mysql_num_fields(S->result)) {
                /* error invalid column */
                pdo_mysql_error_stmt(stmt);
                return FAILURE;

-- EOF --
(also contains CS fixes).

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to