TYPO3 - 在 QueryBuilder API v8 中使用 SQL 运算符
TYPO3 - Using SQL operators in QueryBuilder API v8
如何在此查询中使用 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)
...但没有用。
有效的是:
$queryBuilder->expr()->andX(
$queryBuilder->expr()->gt('uid', $uidMin),
$queryBuilder->expr()->lt('uid', $uidMax)
)
...但是 between() 仍然不起作用...
如何在此查询中使用 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)
...但没有用。
有效的是:
$queryBuilder->expr()->andX(
$queryBuilder->expr()->gt('uid', $uidMin),
$queryBuilder->expr()->lt('uid', $uidMax)
)
...但是 between() 仍然不起作用...