在 Typo3 6.1 版中,我在 My extension Repository 中编写了一些自定义查询
例如在文件 Mytest/Classes/Domain/Repository/MytestRepository.php
class MytestRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
public function myFunction(){
$sql = 'SELECT * FROM some_table ';
$sqlResult = $GLOBALS['TYPO3_DB']->sql_query($sql);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($sqlResult)) {
$rowone = $row['rowone'];
}
}
}
并在控制器中调用该函数
$test = $this->MytestRepository->myFunction();
但这里的问题是,我收到错误
Fatal error: Call to a member function fetch_assoc() on a non-object in /home/src/typo3_src-6.1.1/typo3/sysext/core/Classes/Database/DatabaseConnection.php on line 1029
有人有解决方案吗?提前致谢。