Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.0

Bug #681 Oracle numRows() now returns -1 if no row
Submitted: 2004-02-04 15:45 UTC
From: thierry dot bo at netcourrier dot com Assigned: lsmith
Status: Closed Package: MDB
PHP Version: 4.3.2 OS: Win32 XP
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 7 + 18 = ?

 
 [2004-02-04 15:45 UTC] thierry dot bo at netcourrier dot com
Description: ------------ Using MDB1 latest CVS, recent bug fix #633 and #670 creatad a new bug for Oracle. Now Oracle numRows returns -1 if there is no row in the result set, instead of 0, thus breaking code compatibility with other drivers. Reproduce code: --------------- $res = $mdb->query("SELECT * FROM MTABLE"); $counte = $mdb->numRows($res); Expected result: ---------------- $counte == 0 if no row Actual result: -------------- $counte = -1

Comments

 [2004-02-07 00:45 UTC] thierry dot bo at netcourrier dot com
Hi, I don't know how works the overall MDB api, so the following code may contains stupid things, but here is what I did. As I seen the oci8 numRows() function in DB was quite more simple than MDB one, I tried to use DB code instead in MDB numRows(). With just little changes from DB, here is what I use now: function numRows($result) { if ($this->options['optimize'] == 'portability') { $countquery = "SELECT COUNT(*) FROM (".$this->last_query.")"; $save_query = $this->last_query; $count = $this->query($countquery); if (MDB::isError($count) || MDB::isError($row = $this->fetchRow($count, MDB_FETCHMODE_ORDERED))) { $this->last_query = $save_query; return $this->raiseError(MDB_ERROR_NOT_CAPABLE); } return $row[0]; } return $this->raiseError(MDB_ERROR_NOT_CAPABLE); } For the moment it works with my current application.
 [2004-02-07 22:24 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2004-02-15 16:28 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2004-02-19 00:07 UTC] thierry dot bo at netcourrier dot com
Hi, sorry to open this bug again, but this does not works ever for me. Now the function always returns 0, whatever the number of rows. It seems in the last line of the function : return(max(0, $this->highest_fetched_row[$result_value]; that the return code is based on a varaible ($this->highest_fetched_row[$result_value]) that is never used or set before inside this function. So in all case it is -1. Thierry Bothorel
 [2004-02-25 17:23 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!