note 87109 added to pdostatement.rowcount

From: Date: Wed, 19 Nov 2008 19:30:27 +0000
Subject: note 87109 added to pdostatement.rowcount
Groups: php.notes 
Request: Send a blank email to php-notes+get-146724@lists.php.net to get a copy of this message
As of SQLite 3.x, the SQLite API itself changed and now all queries are implemented using "statements". Because of this, there is no way for PDO to know the rowCount of a SELECT result because the SQLite API itself doesn't offer this ability. As a workaround, I created my own rowCount() function - it's a bit of a hack and hasn't been fully tested yet (I don't know how it will work when using JOINs in SELECTs, etc...), but at least alleviates the necessity for SELECT COUNT(*)'s everywhere in your code. I would have preferred if it were possible to overload the rowCount() function from PDOStatement, but I don't think it's possible (or I don't know how to do it). There's also potential room for a bit more security ensuring that $queryString is wiped clean after other query()s so that you don't get a bad result, etc... The actual code should be posted in the above/below post (max post limits, argh!). If others wish to extend/perfect this method, please keep me posted with an email as to what you've done. ---- Server IP: 69.147.83.197 Probable Submitter: 99.241.132.158 ---- Manual Page -- http://www.php.net/manual/en/pdostatement.rowcount.php Edit -- https://master.php.net/note/edit/87109 Del: integrated -- https://master.php.net/note/delete/87109/integrated Del: useless -- https://master.php.net/note/delete/87109/useless Del: bad code -- https://master.php.net/note/delete/87109/bad+code Del: spam -- https://master.php.net/note/delete/87109/spam Del: non-english -- https://master.php.net/note/delete/87109/non-english Del: in docs -- https://master.php.net/note/delete/87109/in+docs Del: other reasons-- https://master.php.net/note/delete/87109 Reject -- https://master.php.net/note/reject/87109 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#146724) next »