[TYPO3-mvc] Query object and Joins
Dmitri Pisarev
dimaip at gmail.com
Wed Mar 17 18:45:56 CET 2010
How I temporary did it:
/**
* Finds an object matching the given identifier.
*
* @param int $client
* @param int $type
* @return object The matching object if found, otherwise NULL
* @api
*/
public function findByClientAndType($client,$type) {
$query = $this->createQuery();
$query->statement('SELECT * FROM tx_alex_domain_model_tariff LEFT JOIN
tx_alex_domain_model_service ON tx_alex_domain_model_tariff.service =
tx_alex_domain_model_service.uid WHERE
tx_alex_domain_model_service.type='.$type.' AND
tx_alex_domain_model_tariff.client='.$client);
return $query->execute();
}
Still looking how to do it right!
On 17.03.2010 20:30, Dmitri Pisarev wrote:
> Hi!
> I'm still on my way discovering extbase, this time I got to Query object...
>
> I have an object Tariff which has a property service of type Service,
> which has a property type of type Servicetype. So I need to select all
> tariffs of certain type.
> Normally I would create a join for that.
>
> What I already understand:
> 1) Query object doesn't support joins.
> 2) Tx_Extbase_Persistence_QOM_QueryObjectModelFactory has something that
> can help with joins.
> 3) getPreparedQuery function from DataMapper has an example of a joined
> query.
> What I don't understand:
> 1) How to get Tx_Extbase_Persistence_QOM_QueryObjectModelFactory object
> into my TariffRepository. In DataMapper it's being injected in some
> crazy way which I can't grasp at all...
> 2) Does it really need to be so complected? Any plans for introducing
> joins into Query object?
> 3) How should I do it anyway? Just give up and return to SQL?:
> $query->statement('SELECT * FROM tx_alex_domain_model_tariff LEFT JOIN
> tx_alex_domain_model_service ON tx_alex_domain_model_tariff.service =
> tx_alex_domain_model_service.uid');
>
> I shall appreciate any help!
> Dmitri.
More information about the TYPO3-project-typo3v4mvc
mailing list