public static function getTableFields($objDc)
 {
     $blnUnformatted = $objDc->activeRecord->addUnformattedFields && $objDc->activeRecord->type != Exporter::TYPE_ITEM && $objDc->activeRecord->fileType != EXPORTER_FILE_TYPE_MEDIA;
     $blnJoins = $objDc->activeRecord->addJoinTables;
     $arrOptions = static::doGetTableFields($objDc->activeRecord->linkedTable, $blnUnformatted, $blnJoins);
     if ($objDc->activeRecord->addJoinTables) {
         foreach (Helper::getJoinTables($objDc->activeRecord->id) as $strTable) {
             $arrOptions = array_merge($arrOptions, static::doGetTableFields($strTable, $blnUnformatted, $blnJoins));
         }
     }
     return $arrOptions;
 }
 protected function getEntities()
 {
     $arrExportFields = array();
     $arrDca = $GLOBALS['TL_DCA'][$this->linkedTable];
     foreach (deserialize($this->tableFieldsForExport, true) as $strField) {
         if (strpos($strField, EXPORTER_RAW_FIELD_SUFFIX) !== false) {
             $arrExportFields[] = str_replace(EXPORTER_RAW_FIELD_SUFFIX, '', $strField) . ' AS "' . $strField . '"';
         } else {
             $arrExportFields[] = $strField;
         }
     }
     // SELECT
     $strQuery = 'SELECT ' . implode(',', $arrExportFields) . ' FROM ' . $this->linkedTable;
     // JOIN
     if ($this->addJoinTables) {
         $arrJoinTables = Helper::getJoinTablesAndConditions($this->objConfig->id);
         foreach ($arrJoinTables as $joinT) {
             $strQuery .= ' INNER JOIN ' . $joinT['table'] . ' ON ' . $joinT['condition'];
         }
     }
     // WHERE
     $arrWheres = array();
     if ($this->whereClause) {
         $arrWheres[] = html_entity_decode($this->whereClause);
     }
     // limit to archive
     if (TL_MODE == 'BE' && ($this->type == Exporter::TYPE_LIST || !$this->type)) {
         $strAct = \Input::get('act');
         $intPid = \Input::get('id');
         if ($intPid && !$strAct && is_array($arrDca['fields']) && $arrDca['config']['ptable']) {
             $arrWheres[] = 'pid = ' . $intPid;
         }
     }
     if (!empty($arrWheres)) {
         $strQuery .= ' WHERE ' . implode(' AND ', array_map(function ($val) {
             return '(' . $val . ')';
         }, $arrWheres));
     }
     // ORDER BY
     if ($this->orderBy) {
         $strQuery .= ' ORDER BY ' . $this->orderBy;
     }
     return \Database::getInstance()->prepare($strQuery)->execute();
 }