-1

如何在此查询中使用 SQL 运算符 ( https://www.w3schools.com/sql/sql_operators.asp )?比如 $uidMin = 5; $uidMax = 20; ...

$uid = 10;
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
$queryBuilder->getRestrictions()->removeAll();
$statement = $queryBuilder  
    ->select('uid', 'pid', 'header')            
    ->from('tt_content')
    ->where(
       $queryBuilder->expr()->eq('uid', $uid)
    )           
    ->execute();    
while ($row = $statement->fetchAll()) {
    $this->view->assign('inet', $row);
}

我尝试的是例如(http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/query-builder.html)。

$uidMin = 5;
$uidMax = 20;
...
$queryBuilder->expr()->between('uid', $uidMin, $uidMax)

......但没有工作。

4

1 回答 1

0

有效的是:

$queryBuilder->expr()->andX(
    $queryBuilder->expr()->gt('uid', $uidMin),
    $queryBuilder->expr()->lt('uid', $uidMax)
)   

...但是 between() 仍然不起作用...

于 2017-08-24T14:03:08.157 回答