Fwd: [PHP-NOTES] note 11968 added to class.pear.php
| From: | Jesus M. Castagnetto | Date: | Thu, 15 Mar 2001 21:30:56 +0000 |
| Subject: | Fwd: [PHP-NOTES] note 11968 added to class.pear.php | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-23@lists.php.net to get a copy of this message | ||
(Oops forgot that today is the lists' split day)
Some code someone posted to the PEAR section of the
manual, and may be of interest.
I am adding a comment to that note indicating that
code should be contributed to the PEAR list instead.
--- nospamm@pear.net wrote:
> Date: 15 Mar 2001 18:23:48 -0000
> To: php-notes@lists.php.net
> From: nospamm@pear.net
> Subject: [PHP-NOTES] note 11968 added to
> class.pear.php
>
> Hi all!
>
> We've coded a new functionallity for the fetchrow()
> (PEAR). This functionality is work as a datasek.
> Now, you can acess to a specific row of query's
> result. This is usefull for NEXT/PREV buttons and
> more.
> The codification now is only for MySQL. Could any
> people code the other databases?
>
> The $row parameter is the value where you want to
> seek the internal pointer of the fetchrow result.
> Default value is 0.
>
> Modifications in DB.php:
>
> Original function:
>
> function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT)
> {
> if ($fetchmode ==
> DB_FETCHMODE_DEFAULT) {
> $fetchmode =
> $this->dbh->fetchmode;
> }
> return
> $this->dbh->fetchRow($this->result, $fetchmode);
> }
>
> Modified function:
> function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT,
> $row = 0) {
> if ($fetchmode ==
> DB_FETCHMODE_DEFAULT) {
> $fetchmode =
> $this->dbh->fetchmode;
> }
> return
> $this->dbh->fetchRow($this->result, $fetchmode,
> $row);
> }
>
>
>
> Modifications in mysql.php:
>
> Original function:
>
> function &fetchRow($result, $fetchmode =
> DB_FETCHMODE_DEFAULT) {
> if ($fetchmode ==
> DB_FETCHMODE_DEFAULT) {
> $fetchmode =
> $this->fetchmode;
> }
> if ($fetchmode & DB_FETCHMODE_ASSOC)
> {
> $row =
> mysql_fetch_array($result, MYSQL_ASSOC);
> } else {
> $row =
> mysql_fetch_row($result);
> }
> if (!$row) {
> $errno =
> mysql_errno($this->connection);
> if (!$errno) {
> return NULL;
> }
> return
> $this->raiseError($this->errorCode($errno));
> }
> return $row;
> }
>
> Modificated function:
>
> function &fetchRow($result, $fetchmode =
> DB_FETCHMODE_DEFAULT,
> $row = 0) {
>
> if ($row > 0 && $row <
> (mysql_num_rows ($result)-1)) {
> mysql_data_seek ($result,
> $row);
> }
> if ($fetchmode ==
> DB_FETCHMODE_DEFAULT) {
> $fetchmode =
> $this->fetchmode;
> }
> if ($fetchmode & DB_FETCHMODE_ASSOC)
> {
> $row =
> mysql_fetch_array($result, MYSQL_ASSOC);
> } else {
> $row =
> mysql_fetch_row($result);
> }
> if (!$row) {
> $errno =
> mysql_errno($this->connection);
> if (!$errno) {
> return NULL;
> }
> return
> $this->raiseError($this->errorCode($errno));
> }
> return $row;
> }
>
>
> Any feedback and improvements are welcome.
>
> PiLoT & Jazze
>
> http://www.php.net/manual/en/class.pear.php
>
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> php-notes-unsubscribe@lists.php.net
> For additional commands, e-mail:
> php-notes-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
=====
--- Jesus M. Castagnetto <jmcastagnetto@php.net>
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/