[TYPO3-dev] extbase and SQL functions

Adrien Crivelli adrien.crivelli at gmail.com
Wed Jun 1 11:04:35 CEST 2011


Great ! statement() allows me to do exactly the query I want and still get
an Tx_Newsletter_Domain_Model_Email object as a result.

I now use this code:

    public function findByAuthcode($authcode) {
        $query = $this->createQuery();
        $query->statement('SELECT * FROM `tx_newsletter_domain_model_email`
WHERE MD5(CONCAT(`uid`, `recipient_address`)) = ? LIMIT 1',
array($authcode));

        return $query->execute()->getFirst();
    }


This is the obvious thing I missed. Thank you.




On 31 May 2011 11:24, Patrick Schriner <patrick.schriner at diemedialen.de>wrote:

> I may be on the wrong track, but my guess is that you have to use the
> statement() method.
>
>
> On Tue, 31 May 2011 10:58:40 +0200, Adrien Crivelli <
> adrien.crivelli at gmail.com> wrote:
>
>  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)
>>
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
>




More information about the TYPO3-dev mailing list