【问题标题】:TYPO3 - Using SQL operators in QueryBuilder API v8TYPO3 - 在 QueryBuilder API v8 中使用 SQL 运算符
【发布时间】:2017-08-24 12:42:22
【问题描述】:

如何在此查询中使用 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)

...但没有用。

【问题讨论】:

  • between 声明是相当新的学说。你确定你在支持它的版本上运行吗?
  • 似乎 between() 还没有集成:'ExpressionBuilder 类参考'中的api.typo3.org/typo3cms/current/html/…

标签: typo3 typo3-extensions typo3-8.x


【解决方案1】:

有效的是:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-12
    • 2020-11-17
    • 1970-01-01
    • 2020-11-19
    • 1970-01-01
    • 2018-03-08
    • 2023-02-13
    • 1970-01-01
    相关资源
    最近更新 更多