/** * @test */ public function selectDoesNotQuoteStarPlaceholder() { $this->connection->quoteIdentifier('aField')->shouldBeCalled()->willReturnArgument(0); $this->connection->quoteIdentifier('*')->shouldNotBeCalled(); $this->concreteQueryBuilder->select(Argument::exact('aField'), Argument::exact('*'))->shouldBeCalled()->willReturn($this->subject); $this->subject->select('aField', '*'); }
/** * Queries a table for records and completely processes them * * Returns a two-dimensional array of almost finished records; the only need to be put into a <li>-structure * * If you subclass this class, you will most likely only want to overwrite the functions called from here, but not * this function itself * * @param array $params * @param int $recursionCounter The parent object * @return array Array of rows or FALSE if nothing found */ public function queryTable(&$params, $recursionCounter = 0) { $rows = []; $this->params =& $params; $start = $recursionCounter * 50; $this->prepareSelectStatement(); $this->prepareOrderByStatement(); $result = $this->queryBuilder->select('*')->from($this->table)->setFirstResult($start)->setMaxResults(50)->execute(); $allRowsCount = $result->rowCount(); if ($allRowsCount) { /** @var CharsetConverter $charsetConverter */ $charsetConverter = GeneralUtility::makeInstance(CharsetConverter::class); while ($row = $result->fetch()) { // check if we already have collected the maximum number of records if (count($rows) > $this->maxItems) { break; } $this->manipulateRecord($row); $this->makeWorkspaceOverlay($row); // check if the user has access to the record if (!$this->checkRecordAccess($row, $row['uid'])) { continue; } $spriteIcon = $this->iconFactory->getIconForRecord($this->table, $row, Icon::SIZE_SMALL)->render(); $uid = $row['t3ver_oid'] > 0 ? $row['t3ver_oid'] : $row['uid']; $path = $this->getRecordPath($row, $uid); if (strlen($path) > 30) { $croppedPath = '<abbr title="' . htmlspecialchars($path) . '">' . htmlspecialchars($charsetConverter->crop('utf-8', $path, 10) . '...' . $charsetConverter->crop('utf-8', $path, -20)) . '</abbr>'; } else { $croppedPath = htmlspecialchars($path); } $label = $this->getLabel($row); $entry = ['text' => '<span class="suggest-label">' . $label . '</span><span class="suggest-uid">[' . $uid . ']</span><br /> <span class="suggest-path">' . $croppedPath . '</span>', 'table' => $this->mmForeignTable ? $this->mmForeignTable : $this->table, 'label' => $label, 'path' => $path, 'uid' => $uid, 'style' => '', 'class' => isset($this->config['cssClass']) ? $this->config['cssClass'] : '', 'sprite' => $spriteIcon]; $rows[$this->table . '_' . $uid] = $this->renderRecord($row, $entry); } // if there are less records than we need, call this function again to get more records if (count($rows) < $this->maxItems && $allRowsCount >= 50 && $recursionCounter < $this->maxItems) { $tmp = self::queryTable($params, ++$recursionCounter); $rows = array_merge($tmp, $rows); } } return $rows; }
/** * Creates the queryBuilder object whether it is a regular select or a JOIN * * @param Qom\SourceInterface $source The source * @return void */ protected function initializeQueryBuilder(Qom\SourceInterface $source) { if ($source instanceof Qom\SelectorInterface) { $className = $source->getNodeTypeName(); $tableName = $this->dataMapper->getDataMap($className)->getTableName(); $this->tableName = $tableName; $this->queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName); $this->queryBuilder->getRestrictions()->removeAll(); $tableAlias = $this->getUniqueAlias($tableName); $this->queryBuilder->select($tableAlias . '.*')->from($tableName, $tableAlias); $this->addRecordTypeConstraint($className); } elseif ($source instanceof Qom\JoinInterface) { $leftSource = $source->getLeft(); $leftTableName = $leftSource->getSelectorName(); $this->queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($leftTableName); $leftTableAlias = $this->getUniqueAlias($leftTableName); $this->queryBuilder->select($leftTableAlias . '.*')->from($leftTableName, $leftTableAlias); $this->parseJoin($source, $leftTableAlias); } }