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
with no indication what went wrong.
Please read the OTN article to learn about the error modes in PDO.
(I expect everyone to have read this!)
I find setting this:
$dbh->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);
a useful tool while prototyping a script.
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).
Please open bugs via pecl.php.net, as I requested in my call for
testers (where I also mentioned the OTN article, which coincidentally
explained about data coming back as strings), thanks.
Index: ext/pdo_mysql/mysql_statement.c
Please add that to the bug report so that I can find it easily, and
have something to refer to in the changelog.
Thanks,
--Wez.
with no indication what went wrong.
Please read the OTN article to learn about the error modes in PDO.
(I expect everyone to have read this!)I find setting this:
$dbh->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);
a useful tool while prototyping a script.
Which wouldn't have helped because no error was raised at all, no
warning, no notice, no exception, nothing.
[...]
Please add that to the bug report so that I can find it easily, and
have something to refer to in the changelog.
http://pecl.php.net/bugs/bug.php?id=3529
Timm
If it ain't broken, it doesn't have enough features yet