Fixed bug #11119: DBAL: Mapping in query does not takes care of remapping "table...
authorMartin Kutschker <martin.t.kutschker@blackbox.net>
Mon, 15 Jun 2009 19:59:57 +0000 (19:59 +0000)
committerMartin Kutschker <martin.t.kutschker@blackbox.net>
Mon, 15 Jun 2009 19:59:57 +0000 (19:59 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@23899 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/class.ux_t3lib_db.php

index 3c5ab8e..a00dce8 100644 (file)
@@ -2393,12 +2393,22 @@ class ux_t3lib_DB extends t3lib_DB {
 
                                                // do we have a field name in the value?
                                                // this is a very simplistic check, beware
-                                       if(is_array($this->mapping[$t]['mapFieldNames']) && (!is_numeric($sqlPartArray[$k]['value'][0]) && !isset($sqlPartArray[$k]['value'][1]))) {
+                                       if (!is_numeric($sqlPartArray[$k]['value'][0]) && !isset($sqlPartArray[$k]['value'][1])) {
                                                $fieldArray = explode('.', $sqlPartArray[$k]['value'][0]);
-                                               if(count($fieldArray)==1 && isset($this->mapping[$t]['mapFieldNames'][$fieldArray[0]])) {
+                                               if (count($fieldArray) == 1 && is_array($this->mapping[$t]['mapFieldNames']) && isset($this->mapping[$t]['mapFieldNames'][$fieldArray[0]])) {
                                                        $sqlPartArray[$k]['value'][0] = $this->mapping[$t]['mapFieldNames'][$fieldArray[0]];
-                                               } elseif(count($fieldArray)==2 && isset($this->mapping[$t]['mapFieldNames'][$fieldArray[1]])) {
-                                                       $sqlPartArray[$k]['value'][0] = $fieldArray[0].'.'.$this->mapping[$t]['mapFieldNames'][$fieldArray[1]];
+                                               } elseif (count($fieldArray) == 2) {
+                                                               // Map the external table
+                                                       $table = $fieldArray[0];
+                                                       if (isset($this->mapping[$fieldArray[0]]['mapTableName'])) {
+                                                               $table = $this->mapping[$fieldArray[0]]['mapTableName'];
+                                                       }
+                                                               // Map the field itself
+                                                       $field = $fieldArray[1];
+                                                       if (is_array($this->mapping[$fieldArray[0]]['mapFieldNames']) && isset($this->mapping[$fieldArray[0]]['mapFieldNames'][$fieldArray[1]])) {
+                                                               $field = $this->mapping[$fieldArray[0]]['mapFieldNames'][$fieldArray[1]];
+                                                       }
+                                                       $sqlPartArray[$k]['value'][0] = $table . '.' . $field;
                                                }
                                        }