Feature request #6988: Return errors from performUpdateQueries (Thanks to Francois...
authorThomas Hempel <thomas.hempel@typo3.org>
Wed, 19 Dec 2007 21:13:11 +0000 (21:13 +0000)
committerThomas Hempel <thomas.hempel@typo3.org>
Wed, 19 Dec 2007 21:13:11 +0000 (21:13 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2850 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_install.php

index 56a81b7..2c62a95 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-12-19     Thomas Hempel  <thomas@typo3-unleashed.net>
+
+       * Feature request #6988: Return errors from performUpdateQueries (Thanks to Francois Suter)
+
 2007-12-19  Ernesto Baschny <ernst@cron-it.de>
 
        * Feature request #3822, #5065: Make hardcoded (250000 bytes) max attachment size for mailform configurable: $TYPO3_CONF_VARS['FE']['formmailMaxAttachmentSize']
index 8e70a3e..26b4af1 100755 (executable)
@@ -733,16 +733,27 @@ class t3lib_install {
         *
         * @param       array           Array of SQL queries to execute.
         * @param       array           Array with keys that must match keys in $arr. Only where a key in this array is set and true will the query be executed (meant to be passed from a form checkbox)
-        * @return      void
+        * @return      mixed           Array with error message from database if any occured. Otherwise true if everything was executed successfully.
         */
        function performUpdateQueries($arr,$keyArr)     {
+               $result = array();
                if (is_array($arr))     {
                        foreach($arr as $key => $string)        {
                                if (isset($keyArr[$key]) && $keyArr[$key])      {
-                                       $GLOBALS['TYPO3_DB']->admin_query($string);
+                                       $res = $GLOBALS['TYPO3_DB']->admin_query($string);
+                                       if ($res === false)     {
+                                               $result[$key] = $GLOBALS['TYPO3_DB']->sql_error();
+                                       } else {
+                                               $GLOBALS['TYPO3_DB']->sql_free_result($res);
+                                       }
                                }
                        }
                }
+               if (count($result) > 0) {
+                       return $result;
+               } else {
+                       return true;
+               }
        }
 
        /**