fix bug with wrong SQL with static_country_zones
authorfranzholz <franzholz@735d13b6-9817-0410-8766-e36946ffe9aa>
Thu, 23 Nov 2006 13:31:50 +0000 (13:31 +0000)
committerfranzholz <franzholz@735d13b6-9817-0410-8766-e36946ffe9aa>
Thu, 23 Nov 2006 13:31:50 +0000 (13:31 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/static_info_tables/trunk@4124 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
class.tx_staticinfotables_div.php
doc/manual.sxw

index ad46b3f..bdf03a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2006-11-23  Franz Holzinger  <kontakt@fholzinger.com>
+       * fix bug with wrong SQL query with "... AND static_country_zones.=''"
+
 2006-10-31  Franz Holzinger  <kontakt@fholzinger.com>
        * change the param into an addWhere parameter where it is a WHERE clause
 
index f27fd67..da90490 100644 (file)
@@ -227,34 +227,40 @@ class tx_staticinfotables_div {
 
                $title = '';
                $titleFields = tx_staticinfotables_div::getTCAlabelField($table, TRUE, $lang, $local);
-               $prefixedTitleFields = array();
-               foreach ($titleFields as $titleField) {
-                       $prefixedTitleFields[] = $table.'.'.$titleField;
-               }
-               $fields = implode(',', $prefixedTitleFields);
-               $whereClause = '';
-               if (!is_array($isoCode)) {
-                       $isoCode = array($isoCode);
-               }
-               $index = 0;
-               foreach ($isoCode as $index => $code) {
-                       $whereClause .= ($index?' AND ':'').$table.'.'.tx_staticinfotables_div::getIsoCodeField($table, $code, TRUE, $index).'='.$TYPO3_DB->fullQuoteStr($code,$table);
-               }
-
-               if (is_object($TSFE)) {
-                       $enableFields = $TSFE->sys_page->enableFields($table);
-               } else {
-                       $enableFields = t3lib_BEfunc::deleteClause($table);
-               }
-
-               $res = $TYPO3_DB->exec_SELECTquery(
-                       $fields,
-                       $table,
-                       $whereClause.$enableFields
-                       );
-               if ($row = $TYPO3_DB->sql_fetch_assoc($res))    {
+               if (count ($titleFields))       {
+                       $prefixedTitleFields = array();
                        foreach ($titleFields as $titleField) {
-                               if ($row[$titleField]) return $row[$titleField];
+                               $prefixedTitleFields[] = $table.'.'.$titleField;
+                       }
+                       $fields = implode(',', $prefixedTitleFields);
+                       $whereClause = '';
+                       if (!is_array($isoCode)) {
+                               $isoCode = array($isoCode);
+                       }
+                       $index = 0;
+                       foreach ($isoCode as $index => $code) {
+                               $tmpField = tx_staticinfotables_div::getIsoCodeField($table, $code, TRUE, $index);
+                               $tmpValue = $TYPO3_DB->fullQuoteStr($code,$table);
+                               if ($tmpField && $tmpValue)     {
+                                       $whereClause .= ($index?' AND ':'').$table.'.'.$tmpField.' = '.$tmpValue;
+                               }
+                       }
+       
+                       if (is_object($TSFE)) {
+                               $enableFields = $TSFE->sys_page->enableFields($table);
+                       } else {
+                               $enableFields = t3lib_BEfunc::deleteClause($table);
+                       }
+       
+                       $res = $TYPO3_DB->exec_SELECTquery(
+                               $fields,
+                               $table,
+                               $whereClause.$enableFields
+                               );
+                       if ($row = $TYPO3_DB->sql_fetch_assoc($res))    {
+                               foreach ($titleFields as $titleField) {
+                                       if ($row[$titleField]) return $row[$titleField];
+                               }
                        }
                }
 
index e629140..14510a2 100644 (file)
Binary files a/doc/manual.sxw and b/doc/manual.sxw differ