Doc #66613 [Opn]: PDOStatement::columnCount in mysql
| From: | a at enaza dot ru | Date: | Mon, 03 Feb 2014 13:42:59 +0000 |
| Subject: | Doc #66613 [Opn]: PDOStatement::columnCount in mysql | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10942@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
User updated by: a at enaza dot ru
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 think, statement "If there is no result set" could be defined twofold. It should to be
clarified in the documentation.
Previous Comments:
------------------------------------------------------------------------
[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