Doc #66613 [Com]: PDOStatement::columnCount in mysql

From: Date: Sun, 02 Feb 2014 15:48:37 +0000
Subject: Doc #66613 [Com]: PDOStatement::columnCount in mysql
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10937@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 Comment by: jareas at thegeekbeaver dot net Reported by: a at enaza dot ru Summary: PDOStatement::columnCount in mysql Status: Open Type: Documentation Problem Package: PDO MySQL PHP Version: Irrelevant Block user comment: N Private report: N New Comment: 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? Previous Comments: ------------------------------------------------------------------------ [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 (#10937) next »