[TYPO3-dev] extbase and SQL functions

Adrien Crivelli adrien.crivelli at gmail.com
Wed Jun 1 11:21:49 CEST 2011


I don't think it would go against DDD rules as long as it is only allowed in
WHERE clause. See my other post about that:
http://lists.typo3.org/pipermail/typo3-dev/2011-June/043408.html


On 31 May 2011 11:15, Xavier Perseguers <xavier at typo3.org> wrote:

> Hi,
>
>
>  <?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).
>>
>
> I'd say authorizing this would imply some huge refactoring and is not
> DDD-wise as you try to inject SQL code whereas you should only deal with
> field names.
>
>
>  Did I miss an obvious way to achieve this simple goal ?
>>
>
> Either switch to pure SQL and do not use query building from Extbase or add
> an extra column with the computed value and then use it as any other
> standard field.
>
> HTH
>
> --
> Xavier Perseguers
> Release Manager TYPO3 4.6
>
> TYPO3 .... inspiring people to share!
> Get involved: http://typo3.org
>
>
> _______________________________________________
> 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