Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 类型3 8.7.13-MariaDB QueryBuilder全文_Php_Typo3_Mariadb_Typo3 8.x - Fatal编程技术网

Php 类型3 8.7.13-MariaDB QueryBuilder全文

Php 类型3 8.7.13-MariaDB QueryBuilder全文,php,typo3,mariadb,typo3-8.x,Php,Typo3,Mariadb,Typo3 8.x,此查询在phpMyAdmin中与MariaDB一起工作。现在我的“问题”是用QueryBuilder在TYPO3中修改它。我看不出有任何对手或反对接线员 到目前为止,我的功能从以下内容开始: SELECT name FROM tx_snippethighlightsyntax_domain_model_snippets WHERE (MATCH(name, description, code, comment) AGAINST ('css')); TYPO3核心中的扩展索引搜索在查询中使用

此查询在phpMyAdmin中与MariaDB一起工作。现在我的“问题”是用QueryBuilder在TYPO3中修改它。我看不出有任何对手或反对接线员

到目前为止,我的功能从以下内容开始:

SELECT name 
FROM tx_snippethighlightsyntax_domain_model_snippets 
WHERE (MATCH(name, description, code, comment) AGAINST ('css'));

TYPO3核心中的扩展索引搜索在查询中使用匹配和对

下面的代码可以帮助您建立查询

private $tx = 'tx_snippethighlightsyntax_domain_model_snippets';

public function ftsSearch()
    {
        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
        $ftsQueryBuilder = $connectionPool->getQueryBuilderForTable($this->tx);
        $fts = $ftsQueryBuilder
            ->select($this->tx . '.name')
            ->from($this->tx)
            ->where($ftsQueryBuilder->expr()->eq(
                MAGIC HAPPENS HERE ?
            )
            ->execute()
            ->fetchAll();
        return $fts;
    }

这个适合我。谢谢大家!

因此,可以将匹配和反对或任何其他需要的内容连接起来。那帮了大忙!
    $searchBoolean = '';
    if ($searchData['searchBoolean']) {
        $searchBoolean = ' IN BOOLEAN MODE';
    }
    $queryBuilder->andWhere(
        'MATCH (' . $queryBuilder->quoteIdentifier($searchData['fulltextIndex']) . ')'
        . ' AGAINST (' . $queryBuilder->createNamedParameter($searchData['searchString'])
        . $searchBoolean
        . ')'
    );
private $tx = 'tx_snippethighlightsyntax_domain_model_snippets';

public function ftsSearch()
{
    $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
    $ftsQueryBuilder = $connectionPool->getQueryBuilderForTable($this->tx);
    $fts = $ftsQueryBuilder
        ->select($this->tx . '.name')
        ->from($this->tx)
        ->where('MATCH('
            . $this->tx .'.name,'
            . $this->tx .'.description,'
            . $this->tx .'.code,'
            . $this->tx .'.comment)'
            . ' AGAINST(' . $ftsQueryBuilder->createNamedParameter('put_search_here')
            . ')')
        ->execute()
        ->fetchAll();
    return $fts;
}