Bug #77118 [Com]: PDOStatement::fetchColumn() of a non-existing column triggers a warning
Edit report at https://bugs.php.net/bug.php?id=77118&edit=1
ID: 77118
Comment by: v-yitam at microsoft dot com
Reported by: morozov at tut dot by
Summary: PDOStatement::fetchColumn() of a non-existing column
triggers a warning
Status: Open
Type: Bug
Package: PDO OCI
Operating System: Linux
PHP Version: 7.2.11
Block user comment: N
Private report: N
New Comment:
I found another issue also related to PDOStatement::fetchColumn() with an invalid column number, as
described in
https://github.com/Microsoft/msphpsql/issues/968
When PDO::ATTR_ERRMODE is set to PDO::ERRMODE_EXCEPTION, the error message is meaningless, but if
error mode is warning or silent, the error message is actually more helpful.
Previous Comments:
------------------------------------------------------------------------
[2018-11-07 20:22:05] morozov at tut dot by
Description:
------------
When an invalid column number is provided to PDOStatement::fetchColumn(), MySQL, PostgreSQL and
SQLite drivers return NULL without triggering a warning.
Unlike the above, the Oracle driver triggers a misleading warning: column %d data was too large for
buffer and was truncated to fit it.
Test script:
---------------
$conn = new
PDO('oci:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=XE)))',
'system', 'oracle');
// incorrect column, positional parameter
$stmt = $conn->prepare('SELECT ? FROM DUAL');
$stmt->execute([1]);
$value = $stmt->fetchColumn(1);
var_dump($value);
Expected result:
----------------
NULL
Actual result:
--------------
NULL
Warning: PDOStatement::fetchColumn(): column 1 data was too large for buffer and was truncated to
fit it in test.php on line 20
Call Stack:
0.0001 365728 1. {main}() test.php:0
0.0189 372584 2. PDOStatement->fetchColumn() test.php:20
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77118&edit=1
Thread (2 messages)