[TYPO3-mvc] Left join query
Daniel Dimitrov
danielsd_bg at yahoo.fr
Mon Jun 28 11:29:35 CEST 2010
Hey Franz,
"Franz Koch" <typo3.RemoveForMessage at elements-net.de> wrote in message
news:mailman.1.1277712966.8765.typo3-project-typo3v4mvc at lists.typo3.org...
> Hey Daniel,
>
>>> I suppose you have a bidirectional relation, so your keywords know
>>> about your products and your products have keywords assigned. Now you
>>> want to fetch only products with a certain keyword, right? If so, try
>>> this:
>>
>> Do you call bidirectional relation the thing that Felix explained in his
>> mail from 27.05.2010 11:51?
>> mm_oposite_field:
>> http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.1.0/view/4/2/
>>
>> if yes, then yes I have set such relation. I can assign a product to a
>> keyword and a keyword to a product.
>
> yes, that's what I meant.
>
>
>>> class Tx_YourExt_Domain_Repository_ProductRepository extends ... {
>>>
>>> public function findByKeyword (Tx_YourExt_Domain_Model_Keyword
>>> $keyword, $limit=9999, $offset=0, array $orderings) {
>>> $query = $this->createQuery();
>>> return $query->matching(
>>> $query->equals('keywords',$keyword)
>>> )
>>> ->setLimit((integer) $limit)
>>> ->setOffset((integer) $offset)
>>> ->setOrderings($orderings)
>>> ->execute()
>>> }
>>> }
>>
>> I've tried this already, but the sad thing is that I get an array with 0
>> elements. And when introduce an error in the query (ordering by a field
>> that doesn't exist) I see that extbase tries the following query:
>> SELECT tx_bwshop_domain_model_products.* FROM
>> tx_bwshop_domain_model_products WHERE
>> tx_bwshop_domain_model_products.keywords = '623' AND
>> tx_bwshop_domain_model_products.deleted=0 AND
>> tx_bwshop_domain_model_products.hidden=0 AND
>> tx_bwshop_domain_model_products.pid IN (47448, 93) ORDER BY date DESC
>> LIMIT 0, 9999
>
> Then try $query->contains('keywords',$keyword) instead of
> $query->equals('keywords',$keyword). If that still doesn't work there's
> maybe something wrong with your TCA settings.
I was using extbase 1.0.2 and contains was not existing. Now I've udpated to
typo3 4.4 and extabse 1.2
I get this Exception (for contains and equals):
Tx_Extbase_Persistence_Exception_UnexpectedTypeException
Could not determine the child object type.
Does it means that my tca config is wrong???
>
> --
> kind regards,
> Franz Koch
Kind regards,
Daniel
More information about the TYPO3-project-typo3v4mvc
mailing list