[Typo3-dev] DBAL usage question
Rainer Kuhn
kuhn at punkt.de
Fri Apr 22 13:41:41 CEST 2005
Hi all,
I'm going to rewrite my extensions step by step using TYPO3 DBAL. In my
existing non-DBAL code I stored all SQL queries and their results in some
kind of trace log (using my method $this->traceLog()). I would like to keep
this way of logging, so I need the queries assembled by the DBAL functions
as a string for my log.
As I found out in the source, using exec_*query functions (e.g.
$GLOBALS['TYPO3_DB']->exec_SELECTquery()) one can get the 'lastBuiltQuery'
only if $this->debugOutput is true and an error occurs [function debug($func)].
To get the query string independently of errors or debug vars, I tried
$this->traceLog($GLOBALS['TYPO3_DB']->SELECTquery($select, $from, $where,
$groupBy, $orderBy, $limit));
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $from, $where,
$groupBy, $orderBy, $limit);
but this seems to be an overhead as the function SELECTquery(...) is called
twice here (first time inside my traceLog() function, second time inside the
exec_SELECTquery() function).
For not calling it twice, after looking at the CGL concerning the wrapper
class (http://tinyurl.com/bnfxf) I thought about using
$query = $GLOBALS['TYPO3_DB']->SELECTquery($select, $from, $where, $groupBy,
$orderBy, $limit);
$this->traceLog($query);
$res = $GLOBALS['TYPO3_DB']->sql($db, $query);
Is it ok to do so concerning CGL and DBAL, even though the Core API's "high
priority functions (CGL requirements)" list (http://tinyurl.com/bcgur)
requires the exec_*query functions, e.g.
$GLOBALS['TYPO3_DB']->exec_SELECTquery()?
Thanks for your advice,
Rainer
More information about the TYPO3-dev
mailing list