我尝试从 tt_content 获取一些数据进行测试,例如此处的“选择单行”示例(https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Database/BasicCrud/Index.html#select-a-单行):
在 Controller.php 中:
...
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
...
public function listAction() {
$uid = 4;
$tester = GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tt_content')
->select(
['uid', 'pid', 'bodytext'],
'tt_content',
[ 'uid' => (int)$uid ]
)
->fetch() // 1. attempt
->execute(); // 2. attempt
$this->view->assign('inet', $tester);
}
列表.html:
<f:debug>{inet}</f:debug>
我使用 ->execute() 时的调试输出是:
Extbase Variable Dump
TRUE
我使用 ->fetch() 时的调试输出是:
Extbase Variable Dump
FALSE