Fixed bug #8518: Wrong JavaScript inclusion in t3lib_TCEforms
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_db.php
index 795ca2a..4305609 100755 (executable)
@@ -783,6 +783,16 @@ class t3lib_DB {
        }
 
        /**
+        * 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
@@ -898,16 +908,16 @@ class t3lib_DB {
        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);
@@ -1131,12 +1141,12 @@ class t3lib_DB {
 
                $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');
                }
        }