Re: Num rows for postgres
| From: | Stig S. Bakken | Date: | Thu, 25 Jan 2001 09:43:28 +0000 |
| Subject: | Re: Num rows for postgres | ||
| References: | 1 2 3 | Groups: | php.pear |
| Request: | Send a blank email to php-pear+get-1158@lists.php.net to get a copy of this message | ||
Hi Paul,
There is a test for this, pear/DB/tests/pgsql/009.phpt. Could you try
running "php run-tests.php pear/DB/tests/pgsql/009.phpt" from the
top-level PHP directory and let me know whether it fails or succeeds?
(it succeeds on my box). If it fails, please post the contents of
pear/DB/tests/pgsql/009.out here.
- Stig
Paul Meagher wrote:
>
> To answer my own question.
>
> I needed to add this wrapper function to DB.php to get $sth->numRows() to
> work.
>
> /**
> * Get the the number of rows in a result set.
> *
> * @return int the number of rows, or a DB error code
> */
> function numRows() {
> return $this->dbh->numRows($this->result);
> }
>
> Regards,
> Paul
>
> > I am using postgres and I am trying to get the number of results returned
> > by a select query.
> >
> > I would have hoped that something like this would work:
> >
> > $sql = "SELECT * FROM my_table";
> > $sth = $dbh->query($sql);
> > $num_rows = $sth->numRows();
> > echo $num_rows;
> >
> > No go however. Does anyone know how to get the number of rows in a
> result
> > set using the PEAR database abstraction library?
> >
> > Regards,
> > Paul
> >
> >
> >
> >
> > --
> > PHP Extension and Add-on Repository (PEAR) mailing list.
> > Documentation can be found at
> > http://pear.php.net/doc/pear.html
> > To unsubscribe, e-mail: php-pear-unsubscribe@lists.php.net from the
> > mail address you subscribed with.
> >
> >
>
> --
> PHP Extension and Add-on Repository (PEAR) mailing list.
> Documentation can be found at http://pear.php.net/doc/pear.html
> To unsubscribe, e-mail: php-pear-unsubscribe@lists.php.net from the
> mail address you subscribed with.