|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77118 PDOStatement::fetchColumn() of a non-existing column triggers a warning
Submitted: 2018-11-07 20:22 UTC Modified: -
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: morozov at tut dot by Assigned:
Status: Open Package: PDO OCI
PHP Version: 7.2.11 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-11-07 20:22 UTC] morozov at tut dot by
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');
$value = $stmt->fetchColumn(1);

Expected result:

Actual result:

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-12 22:27 UTC] v-yitam at microsoft dot com
I found another issue also related to PDOStatement::fetchColumn() with an invalid column number, as described in

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.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Aug 14 09:05:44 2022 UTC