From: Charlie S. <Sm...@ld...> - 2003-10-22 21:20:20
|
Stephan, The mysql_num_rows fucntion as well as the OCIRowCount only return the = number of rows fetched in the query so far. So, as you've found, all the rows of a particular query have to be fetched = =66or the numrows function to return what most people would want to see - a= = number of the rows matching a specific query. I was wondering how much of this you want to work together on. If you'd= = asked earlier, I would have given you the code that follows. Hopefully, we= = can see the value of working together on this. =20 I'd like a count and names of individuals that would like to participate= .= I believe there was a Jeremy Buckman that showed some interest in this. = Also, I've asked to be put on the developer's list for this project, with = no reply. Is there an objection to this proposal. =20 Here is the code I wrote to return the number of rows matching a particular= = query: Hope this helps. I've also written oracle queries to match all of the mysq= l= queries in phpesp. It's really just a matter of unit testing now. If we= = could have some volunteers to do this, that would be great. Also, = volunteering means, locating the appropriate PEAR db call, and doing the = code to move from the mysql/Oracle calls to the PEAR equivalent if it = exists. I really dont want to offent anyone here, and I've not been able = to pay much attention to this lately, as my other work responsibilities hav= e= caused me to put this on the back burner. However, I believe that with = some effort on all of our parts and - working together - we could proceed t= o= the PEAR port. However, I'm so busy, It really doesn't bother me to wait,= = right now. Just maybe could make life simpler if we share. Here is the oracle function for returning num rows: # Function: oracleNumRows # Author: Charlie Smith # Date: 5/30/03 # Description: # Get number of rows matching query. # # Input Values Description # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # $query Oracle query/statement # $connected resource identifier # # Return Values Description # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # $mcount number of rows in $query # =66unction oracleNumRows($query, $connected) { $cwsStmt =3D oracleExecuteQuery($query, $connected); while($result =3D @oracleFetchArray($cwsStmt)) { } $mCount =3D OCIRowCount($cwsStmt); return $mCount; } # Function: oracleFetchArray # Author: Charlie Smith # Date: 5/30/03 # Description: # Fetch record from table. # # Input Values Description # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # $stmt prepared oracle query # # Return Values Description # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # $row array of values for record retrieved # # NOTE: The known flags to OCIFetchInto are: # OCI_ASSOC Return an associative array. # OCI_NUM Return an numbered array starting with zero. (DEFAULT) # OCI_RETURN_NULLS Return empty columns. # OCI_RETURN_LOBS Return the value of a LOB instead of the descriptor. # =66unction oracleFetchArray($stmt) { @OCIFetchInto ($stmt, $row, OCI_ASSOC); # In case you want to return just one field value, uncommand # and add parameter for name of field. # return $row[$alias_name]; return $row; } # Function: oracleExecuteQuery # Author: Charlie Smith # Date: 5/30/03 # Description: # Executes query on connected resource. # # Calling routines: oracleNumRows # # Input Values Description # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # $query Oracle query/statement # $connected resource identifier # # Return Values Description # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # $stmt Used statement asscociated with parsed/prepared = resource. # =66unction oracleExecuteQuery($query, $connected) { global $ORACLE_USER, $ORACLE_PASS, $ORACLE_SID; if(!$connected) { $connected =3D @OCIPLogon($ORACLE_USER, $ORACLE_PASS, $ORACLE_SID); if($error =3D OCIError()) { die("<font color=3Dred>ERROR!! Couldn't connect to server!</font>"); } } $stmt =3D @OCIParse($connected, $query); if($error =3D OCIError()) { die("<font color=3Dred>ERROR!! Statement syntax error! = $error[message]</font>" ); } @OCIExecute($stmt); if($error =3D OCIError($stmt)) { die("<font color=3Dred>ERROR!! Could not execute statement query:$query= != $erro r[message] </font>"); } return $stmt; } >>> "Stefan Champailler" <sch...@ea...> 10/22/03 01:55PM >>> More on the ODBC port... Since we can't rely on the odbc_num_rows function for counting the result o= =66= =20 select statement, I had to get rid of them all. It took me 1.5 days so far.= =20 Now I have to see where I've broken stuff. I stumbled across a piece of code that is very strange as well. It's in=20 order.inc, the part of the code that actually change the order of a = question.=20 I've a feeling that the SQL statement used is not right. But, somehow,=20 everything seems to work (I didn't investigate completely). So either its=20 wrong, either is quite clever (I need three SQL operation to get the same=20 result). So if someone can explain me how this part of the code is working,= =20 it'll be helpful. stF > Yes, you read well, ODBC port :) > > I'm doing it like that because I have to reduce the risks... Since it's > gonna work on Oracle, I'll share my experience with you. Right now, I'm > converting all the mysal_ statements to odbc_ statements. It's not that > simple. Especially the mysql_num_rows which doesn' translate easily into > odbc_num_rows (this one is not guaranteed to work on every ODBC = driver...). > > More on that later. > > stF > > > > ------------------------------------------------------- > This SF.net email is sponsored by OSDN developer relations > Here's your chance to show off your extensive product knowledge > We want to know what you know. Tell us and you have a chance to win $100 > http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54=20 > _______________________________________________ > phpESP-devel mailing list > php...@li...=20 > https://lists.sourceforge.net/lists/listinfo/phpesp-devel=20 ------------------------------------------------------- This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100 http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54=20 _______________________________________________ phpESP-devel mailing list php...@li...=20 https://lists.sourceforge.net/lists/listinfo/phpesp-devel=20 ---------------------------------------------------------------------------= --- This message may contain confidential information, and is intended only for= = the use of the individual(s) to whom it is addressed. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D |