/**
  * Creates and executes a SELECT query for records from $table and with conditions based on the configuration in the $conf array
  * Implements the "select" function in TypoScript
  * @param $table
  * @param $conf
  * @return resource
  */
 function exec_getQuery($table, $conf)
 {
     $error = 0;
     // Construct WHERE clause:
     if (!$this->conf['dontUsePidList']) {
         if (!strcmp($conf['pidInList'], '')) {
             $conf['pidInList'] = 'this';
         }
     }
     $queryParts = $this->getWhere($table, $conf, TRUE);
     // Fields:
     $queryParts['SELECT'] = $conf['selectFields'] ? $conf['selectFields'] : '*';
     // Setting LIMIT:
     if ($conf['max'] || $conf['begin']) {
         if (!$error) {
             $conf['begin'] = $this->compatibility()->intInRange(ceil($this->cObj->calc($conf['begin'])), 0);
             if ($conf['begin'] && !$conf['max']) {
                 $conf['max'] = 100000;
             }
             if ($conf['begin'] && $conf['max']) {
                 $queryParts['LIMIT'] = $conf['begin'] . ',' . $conf['max'];
             } elseif (!$conf['begin'] && $conf['max']) {
                 $queryParts['LIMIT'] = $conf['max'];
             }
         }
     }
     if (!$error) {
         // Setting up tablejoins:
         $joinPart = '';
         if ($conf['join']) {
             $joinPart = 'JOIN ' . trim($conf['join']);
         } elseif ($conf['leftjoin']) {
             $joinPart = 'LEFT OUTER JOIN ' . trim($conf['leftjoin']);
         } elseif ($conf['rightjoin']) {
             $joinPart = 'RIGHT OUTER JOIN ' . trim($conf['rightjoin']);
         }
         // Compile and return query:
         $queryParts['FROM'] = trim(($this->addFromTable ? $this->addFromTable . ',' : '') . $table . ' ' . $joinPart);
         return $this->db->exec_SELECT_queryArray($queryParts);
     } else {
         return false;
     }
 }