Update of /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/database
In directory usw-pr-cvs1:/tmp/cvs-serv21654/chat/lib/database
Modified Files:
oci8.lib.php3
Log Message:
Too many changes to detail.
Index: oci8.lib.php3
===================================================================
RCS file: /cvsroot/phpmychat/phpMyChat-0.15/chat/lib/database/oci8.lib.php3,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** oci8.lib.php3 2001/04/19 21:05:04 1.4
--- oci8.lib.php3 2001/06/10 15:20:56 1.5
***************
*** 88,99 ****
* Last result of ocipLogon()
*
! * @var string $linkId
*/
var $linkId = 0;
/**
* Result of the most recent OciExecute()
*
! * @var string $queryId
*/
var $queryId = 0;
--- 88,108 ----
* Last result of ocipLogon()
*
! * @var integer $linkId
*/
var $linkId = 0;
/**
+ * The last valid query
+ *
+ * @var string $lastQuery
+ *
+ * @see pmcDB::numRows()
+ */
+ var $lastQuery = '';
+
+ /**
* Result of the most recent OciExecute()
*
! * @var integer $queryId
*/
var $queryId = 0;
***************
*** 233,236 ****
--- 242,246 ----
return 0;
}
+ $this->lastQuery = $queryString;
return $this->queryId;
***************
*** 266,278 ****
* Get the number of rows returned by the last select query
*
* @return integer the number of matching records
*
* @access public
*
! * @todo the whole function!
*/
function numRows()
{
! return ($this->queryId) ? @OCIrowcount($this->queryId) : 0;
} // end of the 'numRows()' method
--- 276,331 ----
* Get the number of rows returned by the last select query
*
+ * The idea of this method is to replace the columns' names to to get
+ * in the previous query by a 'COUNT(*)' statement.
+ *
* @return integer the number of matching records
*
* @access public
*
! * @todo test the whole function!
*/
function numRows()
{
! // No Previous statement -> return 0
! if (!$this->queryId)
! {
! return 0;
! }
! // Previous query was not a 'SELECT' statement -> return error
! else if ( strpos(' ' . $this->lastQuery, 'SELECT') != 1
! || strpos(' ' . $this->lastQuery, 'select') != 1)
! {
! $GLOBALS['currentError']['code'] = 'none';
! $GLOBALS['currentError']['message'] = 'Invalid statement: number of rows can\'t be returned for the last query';
! $this->updateError('pmcDB::numRows()');
! return false;
! }
! // numRows() is a valid function for the previous query
! else
! {
! // Backup some values
! $retLastQueryId = $this->queryId;
! $retLastQuery = $this->lastQuery;
! $retLastRecord = $this->record;
! $retCurrentRow = $this->currentRow;
! // Execute a 'COUNT(*)' statement
! $pos = (strpos($this->lastQuery, ' FROM '))
! ? strpos($this->lastQuery, ' FROM ')
! : strpos($this->lastQuery, ' from ');
! $newQueryString = 'SELECT COUNT(*)'
! . substr($this->lastQuery, $pos);
! $this->query($newQueryString);
! $retCount = $this->record[0];
! // Restore previous backups
! $this->currentRow = $retCurrentRow;
! $this->record = $retLastRecord;
! $setPointer = $this->record[$this->currentRow];
! unset($retLastRecord);
! unset($setPointer);
! $this->lastQuery = $retLastQuery;
! $this->queryId = $retLastQueryId;
!
! return $retCount;
! }
} // end of the 'numRows()' method
|