Doc #66613 [Opn->Ver]: PDOStatement::columnCount and empty result sets

From: Date: Wed, 29 Jun 2016 12:52:41 +0000
Subject: Doc #66613 [Opn->Ver]: PDOStatement::columnCount and empty result sets
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13650@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66613&edit=1 ID: 66613 Updated by: cmb@php.net Reported by: a at enaza dot ru -Summary: PDOStatement::columnCount in mysql +Summary: PDOStatement::columnCount and empty result sets -Status: Open +Status: Verified Type: Documentation Problem -Package: PDO MySQL +Package: PDO related PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2014-02-03 13:42:57] a at enaza dot ru I think, statement "If there is no result set" could be defined twofold. It should to be clarified in the documentation. ------------------------------------------------------------------------ [2014-02-02 15:48:36] jareas at thegeekbeaver dot net I got confused on this one. According to documentation, it supposed to return "0" only if the result set does not exist. It is quite different from result set is empty, in my opinion. What I understood from the documentation is if the $sth object does not have a result set it will return "0". This was illustrated by the documentation on this line: $sth = $dbh->prepare("SELECT name, colour FROM fruit"); Here we still do not have a record set. Then, $sth->columnCount() call will return "0". But, after we actually run the query calling: $sth->execute(); we should get the column count even if the result set is empty. Thats what I understood. What do you think? ------------------------------------------------------------------------ [2014-01-30 12:25:51] a at enaza dot ru Description: ------------ --- From manual page: http://www.php.net/pdostatement.columncount --- According to the documentation, PDOStatement::columnCount() should returns "0", if result set is empty, but i get count fields from query, see example. Test script: --------------- $pdo = new PDO("mysql:host={$host};dbname={$database}", $username, $password); $rs = $pdo->query("SELECT 1,2,3 LIMIT 0"); var_dump($rs->columnCount()); Expected result: ---------------- int(0) Actual result: -------------- int(3) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66613&edit=1

« previous php.doc.bugs (#13650) next »