Made debug logging of user-supplied SQL queries possible in t3lib_db.
authorMartin Kutschker <martin.t.kutschker@blackbox.net>
Thu, 5 Apr 2007 07:41:36 +0000 (07:41 +0000)
committerMartin Kutschker <martin.t.kutschker@blackbox.net>
Thu, 5 Apr 2007 07:41:36 +0000 (07:41 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2252 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_db.php

index 65cab08..d98c600 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 2007-04-05  Martin Kutschker  <martin.t.kutschker@blackbox.net>
 
        * Renamed Typoscript condition julianday to dayofyear (see change from 2007-04-03)
+       * Made debug logging of user-supplied SQL queries possible in t3lib_db.
 
 2007-04-04 Andreas Otto <andreas.otto@dkd.de>
 
@@ -13,7 +14,7 @@
 
 2007-04-03  Dmitry Dulepov  <dmitry@typo3.org>
 
-       * Workspaces: added configurable synchronious stage change and publishing
+       * Workspaces: added configurable synchronous stage change and publishing
 
 2007-04-02  Michael Stucki  <michael@typo3.org>
 
index 9cf155d..9a89c06 100755 (executable)
@@ -741,7 +741,7 @@ class t3lib_DB {
         */
        function sql($db,$query)        {
                $res = mysql_query($query, $this->link);
-               if ($this->debugOutput) $this->debug('sql');
+               if ($this->debugOutput) $this->debug('sql',$query);
                return $res;
        }
 
@@ -755,7 +755,7 @@ class t3lib_DB {
         */
        function sql_query($query)      {
                $res = mysql_query($query, $this->link);
-               if ($this->debugOutput) $this->debug('sql_query');
+               if ($this->debugOutput) $this->debug('sql_query',$query);
                return $res;
        }
 
@@ -1018,7 +1018,7 @@ class t3lib_DB {
         */
        function admin_query($query)    {
                $res = mysql_query($query, $this->link);
-               if ($this->debugOutput) $this->debug('admin_query');
+               if ($this->debugOutput) $this->debug('admin_query',$query);
                return $res;
        }
 
@@ -1080,16 +1080,17 @@ class t3lib_DB {
         * Debug function: Outputs error if any
         *
         * @param       string          Function calling debug()
+        * @param       string          Last query if not last built query
         * @return      void
         */
-       function debug($func)   {
+       function debug($func, $query='')        {
 
                $error = $this->sql_error();
-               if ($error)             {
+               if ($error)     {
                        echo t3lib_div::view_array(array(
                                'caller' => 't3lib_DB::'.$func,
                                'ERROR' => $error,
-                               'lastBuiltQuery' => $this->debug_lastBuiltQuery,
+                               'lastBuiltQuery' => ($query ? $query : $this->debug_lastBuiltQuery),
                                'debug_backtrace' => t3lib_div::debug_trail()
                        ));
                }