[TYPO3-dev] extbase and SQL functions
Adrien Crivelli
adrien.crivelli at gmail.com
Tue May 31 10:58:40 CEST 2011
Hello,
I develop an extension with Typo3 4.5 and extbase. I need to write queries
using SQL functions, such as SELECT * FROM users WHERE MD5(uid);. But I
can't get it to work.
So far I got this code:
<?php
class Tx_Newsletter_Domain_Repository_EmailRepository extends
Tx_Newsletter_Domain_Repository_AbstractRepository {
public function findByAuthcode($authcode) {
$query = $this->createQuery();
$query->setLimit(1);
$c = $query->equals('md5(concat(`uid`, `recipient_address`))',
$authcode);
$query->matching($c);
return $query->execute()->getFirst();
}
}
I debugged the whole thing and figured out that
sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php will
enventually append tablename to any function used. So the query executed
will be similar to:
SELECT tx_newsletter_domain_model_email.* FROM
tx_newsletter_domain_model_email WHERE
tx_newsletter_domain_model_email.md5(concat(`uid`, `recipient_address`)) =
'abc';
instead of :
SELECT tx_newsletter_domain_model_email.* FROM
tx_newsletter_domain_model_email WHERE md5(concat(`uid`,
`recipient_address`)) = 'abc';
I can't find any way to change this behavior and inheriting seems very heavy
(involving inheriting Typo3DbBackend and probably implementing another
Tx_Extbase_Persistence_QOM_SelectorInterface).
Did I miss an obvious way to achieve this simple goal ?
(btw I couldn't find any useful documentation except doc_extbase on git
which does not cover in-depth extbase API)
More information about the TYPO3-dev
mailing list