typo3 - TYPO3 - Scheduler task with custom query
问题描述
I'm using TYPO3 6.2. I created a custom Extbase Task in order to execute it automatically every day.
<?php
namespace Myextension\Scheduler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class Task extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
public function execute()
{
// Custom MySQL query here
}
}
?>
I need to develop a complicated mysql query with a lot of conditions, datas and joins : is it possible not to use $GLOBALS['TYPO3_DB']->exec_SELECTquery
but a method like $GLOBALS['TYPO3_DB']->sql_query(' SELECT * FROM ... ')
?
解决方案
Yes, that's definitely possible.
This is the complete function:
/**
* Executes query
* MySQLi query() wrapper function
* Beware: Use of this method should be avoided as it is experimentally supported by DBAL. You should consider
* using exec_SELECTquery() and similar methods instead.
*
* @param string $query Query to execute
* @return boolean|\mysqli_result|object MySQLi result object / DBAL object
*/
public function sql_query($query) {
$res = $this->query($query);
if ($this->debugOutput) {
$this->debug('sql_query', $query);
}
return $res;
}
And you find it in the file:
typo3/sysext/core/Classes/Database/DatabaseConnection.php
And you can call it like you wrote:
$GLOBALS['TYPO3_DB']->sql_query(' SELECT * FROM ... ')
推荐阅读
- python - 尽管其他应用程序使用了 TensorFlow 并没有使用我所有的 VRAM
- java - 如何在 Spring Boot 中将不同的 JSON 响应消费到客户端的单个端点中?
- php - PHP Regex 忽略特定字符之间的字符串
- ssis - 如何在 SSIS 中的源/目标之间同步数据插入-更新-删除
- node.js - 如何在 forEach 循环节点中使用 Promise?
- java - 使用 AWS SDK for Java 2.x 将大文件上传到 S3 时内存不足
- python - 如何正确使用可选的 argparse 参数和子解析器
- c# - Linq 查询 - 根据条件跳过下一个查询执行
- php - exec:“php-fpm”:在 $PATH 中找不到可执行文件:未知
- c - C语言中的**是什么?