我应该升级到TYPO3 6.2。在一些旧的扩展中,有几个php脚本直接由URL调用。在这些脚本中,他们以下列方式构建数据库连接
define ('PATH_t3lib','t3lib/');
require_once('../../../t3lib/class.t3lib_db.php');
require_once('../../../t3lib/class.t3lib_div.php');
require_once('../../../typo3conf/localconf.php');
define('TYPO3_db_username',$typo_db_username);
define('TYPO3_db_password',$typo_db_password);
define('TYPO3_db_host',$typo_db_host);
define('TYPO3_db',$typo_db);
$db = t3lib_div::makeInstance('t3lib_DB');
$db->connectDB();
$GLOBALS['TYPO3_DB'] = $db;
无论如何都要在TYPO3 6.2中做到这一点。我知道我可以将它包装在扩展中或作为用户功能,但我想保持低功耗。
提前致谢。
答案 0 :(得分:1)
include($_SERVER['DOCUMENT_ROOT'].'/typo3/sysext/core/Classes/Utility/GeneralUtility.php');
include($_SERVER['DOCUMENT_ROOT'].'/typo3/sysext/core/Classes/Database/DatabaseConnection.php');
$localConf = include $_SERVER['DOCUMENT_ROOT'].'/typo3conf/LocalConfiguration.php';
$db = new \TYPO3\CMS\Core\Database\DatabaseConnection();
$db->connectDB($localConf['DB']['host'], $localConf['DB']['username'], $localConf['DB']['password'], $localConf['DB']['database']);
$GLOBALS['TYPO3_DB'] = $db;
所以这有效......