|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2020-06-02 07:39 UTC] cmb@php.net
-Summary: PDOStatement::getColumnMeta should fail
predictably for an empty result set
+Summary: PDOStatement::getColumnMeta fails on empty
result set
-Status: Open
+Status: Verified
-Assigned To:
+Assigned To: cmb
[2020-06-02 07:55 UTC] cmb@php.net
[2020-06-02 08:48 UTC] cmb@php.net
[2020-06-02 08:48 UTC] cmb@php.net
-Status: Verified
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
Description: ------------ PDOStatement::getColumnMeta throws a "column index out of range" error if the result set is empty. After calling PDOStatement::columnCount to confirm that there are columns in the result set, subsequent call to PDOStatement::getColumnMeta shouldn't produce an error even if its implementation does not enable it to fetch the requested column (because there are no rows). Test script: --------------- $pdo = new PDO('sqlite:', null, null, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]); $stmt = $pdo->query('select 1 where 0'); if ($stmt->columnCount()) var_dump($stmt->getColumnMeta(0)); Expected result: ---------------- array(6) { ["native_type"]=> string(7) "integer" ["flags"]=> array(0) { } ["name"]=> string(1) "1" ["len"]=> int(4294967295) ["precision"]=> int(0) ["pdo_type"]=> int(2) } Actual result: -------------- ERROR: SQLSTATE[HY000]: General error: 25 column index out of range