在null上调用成员函数exec_SELECTquery()

时间:2019-06-17 13:10:13

标签: typo3-9.x

我将网站升级到TYPO3 9.5.x,但是升级后出现一些自定义扩展名错误。

(1/1) Error : Call to a member function exec_SELECTquery() on null` in /var/www/example.com/typo3conf/ext/customext/pi1/class.tx_extension_pi1.php line 499

因此我去查看文件,这就是我在499行中找到的内容:

$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $groupBy, $orderBy, $limit);`

2 个答案:

答案 0 :(得分:1)

安装扩展名TYPO3_DB compatibility layer for TYPO3 v9.x/typo3db_legacy,为TYPO3 9+版本提供$GLOBALS['TYPO3_DB']

答案 1 :(得分:0)

不再有TYPO3_DB,他们正在使用新方法。检查此主题,可能会有所帮助:https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Database/Migration/Index.html

UPD。它实际上取决于变量中存储的内容。作为一个基本示例,您可以尝试:

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder->select($select)
->from($table)
->where($where)
->groupBy($groupBy)
->orderBy($orderBy)
->setMaxResults($limit);

// (optional) You can see the built SQL and try to adapt if needed
//  \TYPO3\CMS\Core\Utility\DebugUtility::debug($queryBuilder->getSQL());

$res = $queryBuilder->execute();