[TYPO3-mvc] Query object and Joins

Dmitri Pisarev dimaip at gmail.com
Thu Mar 18 05:43:45 CET 2010


Hi Jochen!
I gave it a try and here's what system returned:
Uncaught TYPO3 Exception
#1247602160: Unknown column 'tx_alex_domain_model_tariff.service.type' 
in 'where clause'
Tx_Extbase_Persistence_Storage_Exception_SqlError thrown in file
C:\_web\xampp\htdocs\typo3_4v4\typo3\sysext\extbase\Classes\Persistence\Storage\Typo3DbBackend.php 
in line 783.

By the way, you seem to have missed a parenthesis after 
$query->equals('client', $client).

PS: I have to correct my function I posted in the previous message:
	public function findByClientAndType($client,$type) {
		$query = $this->createQuery();
		$query->statement('SELECT tx_alex_domain_model_tariff.uid, 
tx_alex_domain_model_tariff.service, tx_alex_domain_model_tariff.client, 
tx_alex_domain_model_tariff.price 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_tariff.client='.$client.' AND 
tx_alex_domain_model_service.type='.$type);
		return $query->execute();
	}	
If I used a SELECT *, then it would obviously overwrite 
tx_alex_domain_model_tariff.uid with 
tx_alex_domain_model_tariff.service.uid.

Thank you Jochen! Now if $query object was really that smart as you say, 
I would have been in love with it completely!

Regards,
Dmitri.
On 17.03.2010 22:12, Jochen Rau wrote:
> Hi Dmitri.
>
> On 17.03.10 18: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.
>
> Give
>
> public function findByClientAndType($client,$type) {
> $query = $this->createQuery();
> $query->matching(
> $query->logicalAnd(
> $query->equals('service.type', $type),
> $query->equals('client', $client)
> );
> return $query->execute();
> }
>
> a try.
>
> Regards
> Jochen
>



More information about the TYPO3-project-typo3v4mvc mailing list