}
/**
+ * Returns the error number on the last sql() execution
+ * mysql_errno() wrapper function
+ *
+ * @return int MySQL error number.
+ */
+ function sql_errno() {
+ return mysql_errno($this->link);
+ }
+
+ /**
* Returns the number of selected rows.
* mysql_num_rows() wrapper function
* Usage count/core: 85
function sql_pconnect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password) {
// mysql_error() is tied to an established connection
// if the connection fails we need a different method to get the error message
- ini_set('track_errors', 1);
- ini_set('html_errors', 0);
+ @ini_set('track_errors', 1);
+ @ini_set('html_errors', 0);
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']) {
$this->link = @mysql_connect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password);
} else {
$this->link = @mysql_pconnect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password);
}
$error_msg = $php_errormsg;
- ini_restore('track_errors');
- ini_restore('html_errors');
+ @ini_restore('track_errors');
+ @ini_restore('html_errors');
if (!$this->link) {
t3lib_div::sysLog('Could not connect to MySQL server '.$TYPO3_db_host.' with user '.$TYPO3_db_username.': '.$error_msg,'Core',4);
$output = array();
$columns_res = mysql_query('SHOW CHARACTER SET', $this->link);
- while ($row = mysql_fetch_assoc($columns_res)) {
- $output[$row['Charset']] = $row;
+ if ($columns_res) {
+ while (($row = mysql_fetch_assoc($columns_res))) {
+ $output[$row['Charset']] = $row;
+ }
}
return $output;
$error = $this->sql_error();
if ($error) {
- echo t3lib_div::view_array(array(
+ debug(array(
'caller' => 't3lib_DB::'.$func,
'ERROR' => $error,
'lastBuiltQuery' => ($query ? $query : $this->debug_lastBuiltQuery),
'debug_backtrace' => t3lib_div::debug_trail()
- ));
+ ), 'SQL debug');
}
}