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

From: Date: Wed, 29 Jun 2016 12:54:07 +0000
Subject: Doc #66613 [Ver->Csd]: PDOStatement::columnCount and empty result sets
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13651@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 and empty result sets -Status: Verified +Status: Closed Type: Documentation Problem Package: PDO related PHP Version: Irrelevant Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2016-06-29 12:53:29] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=339522 Log: Fix #66613: PDOStatement::columnCount and empty result sets ------------------------------------------------------------------------ [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 (#13651) next »