Fwd: [PHP-NOTES] note 11968 added to class.pear.php
[email protected] ("Jesus M. Castagnetto") Thu, 15 Mar 2001 13:27:10 -0800 (PST)
| Newsgroups | php.pear |
|---|---|
| Message-ID | <[email protected]> |
Thought some of you guys may want to take a look at this. --- [email protected] wrote: > Date: 15 Mar 2001 18:23:48 -0000 > To: [email protected] > From: [email protected] > 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: > [email protected] > For additional commands, e-mail: > [email protected] > To contact the list administrators, e-mail: > [email protected] > ===== --- Jesus M. Castagnetto <[email protected]> __________________________________________________ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices. http://auctions.yahoo.com/