Index: db_connection.php =================================================================== --- db_connection.php (revision 155) +++ db_connection.php (working copy) @@ -258,7 +258,7 @@ $func = $this->getMetaFunction('error'); $this->errorMessage = $this->connectionID ? $func($this->connectionID) : $func(); $error_msg = 'Database connection failed, please check your connection settings.
Error (' . $this->errorCode . '): ' . $this->errorMessage; - + trigger_error($error_msg, defined('IS_INSTALL') && IS_INSTALL ? E_USER_WARNING : E_USER_ERROR); } @@ -475,6 +475,93 @@ return false; } + /** + * 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 + + $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; + } + + $this->showError($select_sql); + + return false; + } + + /** + * 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); @@ -546,21 +633,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 *