Index: db_connection.php =================================================================== --- db_connection.php (revision 14476) +++ db_connection.php (working copy) @@ -310,7 +310,7 @@ function showError($sql = '', $key_field = null, $no_debug = false) { static $retry_count = 0; - + $func = $this->getMetaFunction('errno'); if (!$this->connectionID) { @@ -546,6 +546,92 @@ return $this->showError($sql, $key_field, $no_debug); } + /** + * Retrieves data from database and return resource id on success or false otherwise + * + * @param string $select_sql + * @param string $key_field + * @return resource + * @see kDBConnection::GetNextRow + */ + function QueryRaw($select_sql) + { + $this->lastQuery = $select_sql; + $this->_queryCount++; + + $query_func = $this->getMetaFunction('query'); + + // set 1st checkpoint: begin + if ($this->_captureStatistics) { + $start_time = getmicrotime(); + } + // set 1st checkpoint: end + + $this->setError(0, ''); // reset error + $resource = $query_func($select_sql, $this->connectionID); + + // set 2nd checkpoint: begin + if ($this->_captureStatistics) { + $query_time = getmicrotime() - $start_time; + if ($query_time > DBG_MAX_SQL_TIME) { + $this->Application->logSlowQuery($select_sql, $query_time); + } + $this->_queryTime += $query_time; + } + // set 2nd checkpoint: end + + if ( is_resource($resource) ) { + return $resource; + } + + return $this->showError($select_sql); + } + + /** + * Returns row count in recordset + * + * @param resource $resource + * @return int + */ + function RowCount($resource) + { + $count_func = $this->getMetaFunction('num_rows'); + + return $count_func($resource); + } + + /** + * Returns next available row from recordset + * + * @return Array + */ + function GetNextRow($resource) + { + $fetch_func = $this->getMetaFunction('fetch_assoc'); + + return $fetch_func($resource); + } + + /** + * Free memory used to hold recordset handle + * + * @param resource $resource + * @access private + */ + function Destroy($resource = null) + { + if ( !isset($resource) ) { + $resource = $this->queryID; + } + + if ( $resource ) { + $free_func = $this->getMetaFunction('free_result'); + $free_func($resource); + + $this->queryID = null; + } + } + function ChangeQuery($sql) { $this->Query($sql); @@ -618,21 +704,6 @@ } /** - * Free memory used to hold recordset handle - * - * @access private - */ - function Destroy() - { - if($this->queryID) - { - $free_func = $this->getMetaFunction('free_result'); - $free_func($this->queryID); - $this->queryID = null; - } - } - - /** * Returns auto increment field value from * insert like operation if any, zero otherwise *