numRows() for oci8

From: Date: Wed, 24 Jan 2001 09:37:53 +0000
Subject: numRows() for oci8
Groups: php.pear 
Request: Send a blank email to php-pear+get-1143@lists.php.net to get a copy of this message
Hi, has anybody a good idea to get numrows of an oracle result? maybe something this: (could be implemented in the same way at the oci7 api) // {{{ numRows() /** * Get the number of rows in a result set. * * @param $query query of the select * * @access public * * @return int the number of rows in $result */ function numRows($query=FALSE) { if(!$query){ $query=$this->last_query; } $query=$this->modifyQuery($query); if(!preg_match('/^\s*SELECT/i', $query)){ return 0; } $query="SELECT COUNT(*) FROM (".$query.")"; if(!$stmt= @OCIParse($this->connection, $query)){ return $this->raiseError(); } if(!$success=@OCIExecute($stmt,OCI_DEFAULT)){ return $this->raiseError(); } if(!$data=@OCIFetchInto($stmt,$result,OCI_ASSOC+OCI_RETURN_NULLS){ return $this->raiseError(); } return $result["COUNT(*)"]; } // }}} ( its untestet, just quick written in the mailclient... ) maybe we can rewrite the original query and replace all selected fields with one count(*), that could be better ;-) any better ideas? another thing is, why not using @ in front of each databasefunction? if an error occurs, raiseError() schould do the rest. regards.. thomas -- -------------------------------------------------------------------------- http://phporacleadmin.org http://tfromm.com http://inubit.com "go away or I will replace You with a small PHP script!"

« previous php.pear (#1143) next »