我正在测试DataHandler functionalities的后端模块,而我的简单脚本会导致错误。
脚本部分:
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\DataHandling\DataHandler;
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$cmd['pages']['2224']['delete'] = 1;
$dataHandler->start([], $cmd);
$dataHandler->process_cmdmap();
错误:
致命错误:未捕获的学说\ DBAL \ Driver \ Mysqli \ MysqliException: 在“字段列表”中的未知列“ uid” /var/www/vhosts/#mysite#/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php:94 堆栈跟踪:#0 /var/www/vhosts/#mysite#/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php(120): Doctrine \ DBAL \ Driver \ Mysqli \ MysqliStatement-> __ construct(Object(mysqli), 'SELECT
uid
FR ...')#1 /var/www/vhosts/#mysite#/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(844):Doctrine \ DBAL \ Driver \ Mysqli \ MysqliConnection-> prepare('SELECTuid
FR ...')#2 /var/www/vhosts/#mysite#/vendor/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(206): Doctrine \ DBAL \ Connection-> executeQuery('SELECTuid
FR ...',Array, 阵列)#3 /var/www/vhosts/#mysite#>/typo3/sysext/core/Classes/Database/Query/QueryBuilder.php(187): Doctrine \ DBAL \ Query \ QueryBuilder-> execute()#4在 /var/www/vhosts/#mysite#/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php 在第71行
我不明白它是如何找不到标准表页面上肯定具有的uid
字段的。。。有人知道我可以尝试做些什么吗?
我用于插入和更新页面的其他脚本也可以正常工作-像这样:
$newPage = array(
'pid' => 3,
'hidden' => 0,
'title' => 'test'
);
$data['pages']['NEW_10'] = $newPage;
$dataHandler->start($data, []);
$dataHandler->process_datamap();
EDIT我找到了解决方案,但未使用此方法
现在仅应使用DataHandler
来解决特定问题,我的解决方法是这样(找到here):
GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages')
->delete(
'pages',
[ 'uid' => (int)2224]
);