php.net |  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: -
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (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
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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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 
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 02:02:52 2024 UTC