/** * @throws Exception * @return array of options */ protected function getDataFromSqlServer() { $query = $this->dbObj->SELECTquery($this->selectPart, $this->fromPart, $this->wherePart, $this->groupByPart, $this->orderByPart, $this->limitPart); // this method only combines the parts $dataSource = Tx_PtExtlist_Domain_DataBackend_DataBackendFactory::getInstanceByListIdentifier($this->filterConfig->getListIdentifier())->getDataSource(); if (!method_exists($dataSource, 'executeQuery')) { throw new Exception('The defined dataSource has no method executeQuery and is therefore not usable with this dataProvider!', 1315216209); } $data = $dataSource->executeQuery($query)->fetchAll(); if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('MYSQL QUERY : ' . $this->filterConfig->getListIdentifier() . ' -> Filter::ExplicitSQLQuery', 'pt_extlist', 1, array('executionTime' => $dataSource->getLastQueryExecutionTime(), 'query' => $query)); } return $data; }
/** * Precompiles a SELECT prepared SQL statement. * * @param array $components * @return array Precompiled SQL statement */ protected function precompileSELECTquery(array $components) { $parameterWrap = '__' . dechex(time()) . '__'; foreach ($components['parameters'] as $key => $params) { if ($key === '?') { foreach ($params as $index => $param) { $components['parameters'][$key][$index][0] = $parameterWrap . $param[0] . $parameterWrap; } } else { $components['parameters'][$key][0] = $parameterWrap . $params[0] . $parameterWrap; } } $select_fields = $this->SQLparser->compileFieldList($components['SELECT']); $from_table = $this->SQLparser->compileFromTables($components['FROM']); $where_clause = $this->SQLparser->compileWhereClause($components['WHERE']); $groupBy = $this->SQLparser->compileFieldList($components['GROUPBY']); $orderBy = $this->SQLparser->compileFieldList($components['ORDERBY']); $limit = $components['LIMIT']; $precompiledParts = array(); $this->lastHandlerKey = $this->handler_getFromTableList($components['ORIG_tableName']); $hType = (string) $this->handlerCfg[$this->lastHandlerKey]['type']; $precompiledParts['handler'] = $hType; $precompiledParts['ORIG_tableName'] = $components['ORIG_tableName']; switch ($hType) { case 'native': $query = parent::SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit); $precompiledParts['queryParts'] = explode($parameterWrap, $query); break; case 'adodb': $query = parent::SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy); $precompiledParts['queryParts'] = explode($parameterWrap, $query); $precompiledParts['LIMIT'] = $limit; break; case 'userdefined': $precompiledParts['queryParts'] = array('SELECT' => $select_fields, 'FROM' => $from_table, 'WHERE' => $where_clause, 'GROUPBY' => $groupBy, 'ORDERBY' => $orderBy, 'LIMIT' => $limit); break; } return $precompiledParts; }
/** * Creates a SELECT SQL-statement * Usage count/core: 11 * * @param string See exec_SELECTquery() * @param string See exec_SELECTquery() * @param string See exec_SELECTquery() * @param string See exec_SELECTquery() * @param string See exec_SELECTquery() * @param string See exec_SELECTquery() * @return string Full SQL query for SELECT */ public function SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy = '', $limit = '') { $this->lastHandlerKey = $this->handler_getFromTableList($from_table); $hType = (string) $this->handlerCfg[$this->lastHandlerKey]['type']; if ($hType === 'adodb' && $this->runningADOdbDriver('postgres')) { // Possibly rewrite the LIMIT to be PostgreSQL-compatible $splitLimit = t3lib_div::intExplode(',', $limit); // Splitting the limit values: if ($splitLimit[1]) { // If there are two parameters, do mapping differently than otherwise: $numrows = $splitLimit[1]; $offset = $splitLimit[0]; $limit = $numrows . ' OFFSET ' . $offset; } } $select_fields = $this->quoteFieldNames($select_fields); $from_table = $this->quoteFromTables($from_table); $where_clause = $this->quoteWhereClause($where_clause); $groupBy = $this->quoteGroupBy($groupBy); $orderBy = $this->quoteOrderBy($orderBy); // Call parent method to build actual query $query = parent::SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit); if ($this->debugOutput || $this->store_lastBuiltQuery) { $this->debug_lastBuiltQuery = $query; } return $query; }