note 123744 added to pdostatement.rowcount
| From: | bohwaz@php.net | Date: | Fri, 05 Apr 2019 12:42:57 +0000 |
| Subject: | note 123744 added to pdostatement.rowcount | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210528@lists.php.net to get a copy of this message | ||
Please note another interesting behavior with PostgreSQL.
If you try to use rowCount() after a statement has been prepared using the PDO::ATTR_CURSOR set to
PDO::CURSOR_SCROLL you will always get zero (0).
That's because PG doesn't have any way to tell how many rows are in the cursor until it
did iterate through all rows.
<?php
$st = $pdo->prepare('SELECT NOW();', [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL]);
$st->execute();
var_dump($st->rowCount());
?>
Will return "0", whereas the same statement without the CURSOR_SCROLL attribute, will
correctly return 1.
Please see this bug report https://bugs.php.net/bug.php?id=77855 for details.
This documentation should be updated shortly to reflect that issue.
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.194 (proxied: 92.154.106.119)
----
Manual Page -- http://php.net/manual/en/pdostatement.rowcount.php
Edit -- https://master.php.net/note/edit/123744
Del: integrated -- https://master.php.net/note/delete/123744/integrated
Del: useless -- https://master.php.net/note/delete/123744/useless
Del: bad code -- https://master.php.net/note/delete/123744/bad+code
Del: spam -- https://master.php.net/note/delete/123744/spam
Del: non-english -- https://master.php.net/note/delete/123744/non-english
Del: in docs -- https://master.php.net/note/delete/123744/in+docs
Del: other reasons-- https://master.php.net/note/delete/123744
Reject -- https://master.php.net/note/reject/123744
Search -- https://master.php.net/manage/user-notes.php