public function getDisplayColumns()
 {
     if (empty($this->displayColumns)) {
         return $this->source->getDisplayColumns();
     }
     return $this->displayColumns;
 }
Beispiel #2
0
 /**
  * Execute the query and set up the results iterator
  * @param string|array $formName (if array, must be array of string)
  * @param null|string $submitTimeKeyName
  * @return void
  */
 protected function setDataIterator($formName, $submitTimeKeyName = null)
 {
     $submitTimes = $this->queryRandomSubmitTimes($formName);
     $sql = $this->getPivotQuery($formName, false, $submitTimes);
     $queryOptions = array();
     if ($submitTimeKeyName) {
         $queryOptions['submitTimeKeyName'] = $submitTimeKeyName;
     }
     if (isset($this->options['limit']) && $this->hasFilterOrTransform()) {
         // have data iterator apply the limit if it is not already
         // being applied in SQL directly, which we do when there are
         // no filter constraints.
         $queryOptions['limit'] = $this->options['limit'];
     }
     $unbuffered = false;
     if (isset($this->options['unbuffered'])) {
         $queryOptions['unbuffered'] = $this->options['unbuffered'];
         $unbuffered = $queryOptions['unbuffered'] == 'true';
     }
     if ($this->debug) {
         $queryOptions['debug'] = 'true';
     }
     $this->dataIterator = CFDBQueryResultIteratorFactory::getInstance()->newQueryIterator($unbuffered);
     if ($this->transform && !empty($this->transform->transformIterators)) {
         $postProcessOptions = $queryOptions;
         // make a copy
         // If we have a transform, then alternatively-named options like 'tlimit' are used
         // in the actual query (CFDBQueryResultIterator) whereas the normally named
         // ones are handled by the CFDBTransformEndpoint post-processor
         unset($queryOptions['limit']);
         if (isset($this->options['tlimit'])) {
             $queryOptions['limit'] = $this->options['tlimit'];
         }
         unset($queryOptions['orderby']);
         if (isset($this->options['torderby'])) {
             $queryOptions['orderby'] = $this->options['torderby'];
         }
         // These aren't really needed b/c we have already setup $this->rowTransformFilter
         unset($queryOptions['filter']);
         if (isset($this->options['tfilter'])) {
             $queryOptions['filter'] = $this->options['tfilter'];
         }
         unset($queryOptions['search']);
         if (isset($this->options['tsearch'])) {
             $queryOptions['search'] = $this->options['tsearch'];
         }
         $this->dataIterator->query($sql, $this->rowTransformFilter, $queryOptions);
         $queryDisplayColumns = $this->getColumnsToDisplay($this->dataIterator->columns);
         $this->transform->setTimezone();
         // Hookup query iterator as first transform, hookup last iterator as $this->dataIterator
         $this->transform->setDataSource($this->dataIterator);
         $this->dataIterator = $this->transform->getIterator();
         // $this->dataIterator is a CFDBTransformEndpoint
         $this->dataIterator->getPostProcessor()->query($sql, $this->rowFilter, $postProcessOptions);
         $displayColumns = $this->getColumnsToDisplay($this->dataIterator->getDisplayColumns());
         // Not sure why I need to do this to make show/hide work in some cases
         $this->dataIterator->displayColumns = empty($displayColumns) ? $queryDisplayColumns : $displayColumns;
     } else {
         // No transform, just query
         $this->dataIterator->query($sql, $this->rowFilter, $queryOptions);
         $this->dataIterator->displayColumns = $this->getColumnsToDisplay($this->dataIterator->columns);
     }
 }