Edit report at http://bugs.php.net/bug.php?id=52104&edit=1
ID: 52104 User updated by: daniel dot baulig at gmx dot de Reported by: daniel dot baulig at gmx dot de Summary: bindColumn creates Warning regardless of ATTR_ERRMODE settings Status: Open Type: Bug Package: PDO related Operating System: Windows 7 / Debian PHP Version: 5.3.2 New Comment: I looked into 5.3 SVN source code and was able to spot the problem. The following line is causing the Warning: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Did not found column name '%s' in the defined columns; it will not be bound", param->name); I believe it should be replaced by something like the following: pdo_raise_impl_error(stmt->dbh, stmt, "?????", "Did not found column name in the defined columns; it will not be bound" TSRMLS_CC); I also believe "Did not found column name" is not proper english and should either be "Did not find column name" or "Column name not found". I also do not know the exact meaning of the error codes used in other pdo_raise_impl_error like "HY093", so an appropriate errorcode for this error should be inserted instead of the question marks. Previous Comments: ------------------------------------------------------------------------ [2010-06-16 22:47:15] daniel dot baulig at gmx dot de Description: ------------ If you call bindColumn on a non existent column it will always create a warning, no matter how the PDO object is configured to respond to errors (ERRMODE_EXCEPTION, ERRMODE_SILENT, ERRMODE_WARNING). I actually recreated this on PHP 5.3.1 and PHP 5.2.6-1+lenny8 (from Debian Lenny repository) and have NOT tried it on 5.3.2. Since I was not able to find any references for this bug on the web, I believe I might be the first one to encounter it and it is propably not fixed as of PHP 5.3.2 Test script: --------------- $pdo = new PDO('mysql:host=localhost;dbname=db', 'root', ''); $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $statement = $pdo->prepare('SELECT id FROM aTable'); $statement->execute(); $field= NULL; try { $statement->bindColumn('none_existent_field', $field, PDO::PARAM_INT); while ($statement->fetch( PDO::FETCH_BOUND )) { echo $field. "<br/>\n"; } } catch (PDOException $e) { echo "Database field not in result set!<br/>\n"; } Expected result: ---------------- The string "Database field not in result set!<br/>\n"; Actual result: -------------- A warning: <b>Warning</b>: PDOStatement::bindColumn() [<a href='pdostatement.bindcolumn'>pdostatement.bindcolumn</a>]: Did not found column name 'none_existent_field' in the defined columns; it will not be bound in <b>/path/to/script.php</b> on line <b>10</b><br /> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52104&edit=1