[TYPO3-mvc] output the created sql
Jochen Rau
jochen.rau at typoplanet.de
Mon Apr 19 12:04:51 CEST 2010
Hi Daniel.
On 19.04.10 11:30, Daniel Dimitrov wrote:
> Dear list :),
> I'm trying to write my own pagebrowser.
> I have a function that returns my database entries with a limit.
>
> public function findAllWithLimit($offset = 0, $limit = 5) {
> $query = $this->createQuery();
>
> return $query->matching()
> ->setLimit((integer)$limit)
> ->setOffset((integer)$offset)
> ->setOrderings(array('crdate' =>
> Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING))
> ->execute();
> }
>
> I'm wondering if there is an easy way to return the query that this
> function generates?
Not now. You might want to file a feature request on
http://forge.typo3.org/projects/typo3v4-mvc/issues
in the meantime you can uncomment the existing debug statements in
Tx_Extbase_Persistence_Storage_Typo3DbBackend which is, of course, not
the final solution.
> In Joomla it is really easy to see the output of the query:
> $db = JFactory::getDBO();
> $query = 'some query';
> $db->setQuery($query);
> var_dump($db->_sql);
Ok, no Joomla bashing here ;-)
But in Joomla, you set the query as a plain string (which is also
possible with $query->statement('SELECT * ...') in Extbase). It is
stored in a public readable property $_sql (which is very bad design IMO).
But they have implemented $db->explain() which gives a nice printout of
the SQL query behavior. We could implement this in Extbase, too. So you
can use $query->explain() instead of $query->execute().
Regards
Jochen
More information about the TYPO3-project-typo3v4mvc
mailing list