Hallo liebe Leute,
ich muss aus einer Extension auf eine andere Datenbank zugreifen. Soweit kein Problem, gefunden habe ich eine Möglichkeit:
In der ext_localconf.php steht:
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
$TYPO3_CONF_VARS['EXTCONF']['dbal']['handlerCfg'] = array (
'_DEFAULT' => array (
'type' => 'native',
'config' => array(
'username' => '', // Set by default (overridden)
'password' => '', // Set by default (overridden)
'host' => '', // Set by default (overridden)
'database' => '', // Set by default (overridden)
)
),
'alternativeMySQLdb' => array (
'type' => 'native',
'config' => array(
'driver' => 'mysql',
'username' => 'xxx',
'password' => 'xxx',
'host' => 'localhost',
'database' => 'xyz'
)
)
);
$TYPO3_CONF_VARS['EXTCONF']['dbal']['table2handlerKeys'] = array (
'tabellenname_aus_alternativer_db' => 'alternativeMySQLdb'
);
$TYPO3_CONF_VARS['EXTCONF']['dbal']['debugOptions'] = array(
'enabled' => TRUE, // Generally, enable debugging.
'printErrors' => TRUE, // Enable output of SQL errors after query executions.
'EXPLAIN' => 1, // EXPLAIN SELECT ...(Only on default handler)
'parseQuery' => 1 // Parsing queries, testing parsability (All queries)
);
?>
In der main-Methode der Ausgabeklasse der Extension steht folgendes:
<?php
...
function main($content, $conf) {
$this->conf = $conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
$ressource = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
'tabellenname_aus_alternativer_db',
'',
'',
'',
''
);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($ressource)) {
foreach($row as $key => $value) {
$content .= $key." => ".$value."<br>";
}
}
return $this->pi_wrapInBaseClass($content);
}
...
?>
Problem ist, es funktioniert nicht oder besser: es passiert NICHTS. Ersetze ich den tabellenname_aus_alternativer_db durch z.B. tt_content wird direkt der Inhalt von tt_content ausgespuckt.
Sieht jemand auf Anhieb den Fehler oder hat jemand eine Idee wie ich weiter debuggen kann? Weiteres Problem ist, das System sagt mir nichts.
Beide Datenbanken sind auf localhost. Benutzer und Passwort habe ich mehrfach geprüft.
Hinweis: http://typo3.org/documentation/document-library/extension-manuals/dbal/1.0.0/view/1/3/
Wo zum Henker finde ich das? #giggle# Die Options dazu habe ich in der ext_localconf.php initialisiert.
Danke für Eure Tipps.
Viele Grüße
Herb