Re: [PDO] Number of rows found by Select
| From: | Micah Stevens | Date: | Tue, 08 Nov 2005 17:24:49 +0000 |
| Subject: | Re: [PDO] Number of rows found by Select | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40625@lists.php.net to get a copy of this message | ||
There's a function called 'found_rows()' function, so you could try issuing a
query, then issuing a second one 'SELECT FOUND_ROWS();' and it should give
the number of rows returned by the previous select.
Here's details:
http://dev.mysql.com/doc/refman/4.1/en/information-functions.html
On Tuesday 08 November 2005 9:13 am, Micah Stevens wrote:
> yeah, it would help if I read the whole post. Sorry.
>
> On Tuesday 08 November 2005 9:06 am, Dwight Altman wrote:
> > I suppose you could use "count( PDOStatement::fetchAll() )", but I
> > understand your amazement.
> >
> > mysql_num_rows() is specific to MySQL. He wants a PDO version.
> >
> > -----Original Message-----
> > From: Micah Stevens [mailto:micah@raincross-tech.com]
> > Sent: Tuesday, November 08, 2005 10:51 AM
> > To: php-db@lists.php.net
> > Subject: Re: [PHP-DB] [PDO] Number of rows found by Select
> >
> >
> >
> > mysql_num_rows()
> >
> > On Tuesday 08 November 2005 5:17 am, Rob C wrote:
> > > What is the recommended way to find the number of rows found by a
> > > SELECT query? PDOStatement::rowCount() doesn't work with MySQL and is a
> > > bit of a hack anyway. Doing a COUNT(*) before the SELECT is very
> > > hackish - the data could have changed and it's an extra query. What is
> > > there that's better than either of these? Is there any way to use
> > > COUNT(*) without risking data change, such as inside a transaction?
> > >
> > > I'm amazed that there is no mysql_num_rows() equivilent, I get the
> > > feeling that I'm missing something obvious. I can only presume there is
> > > some technical limitation that I'm not appreciating, if anyone can shed
> > > some light on this, I'd like to know.
> > >
> > > I'm new to both PDO and this mailing list, so please be gentle with me.
> > > I'm using PDO 1.0RC2, PHP 5.0.5 and MySQL 4.1.15.
> > >
> > > Rob
> >
> > --