[TYPO3-mvc] Join with QOM
Pankaj Lele
pankaj at lelesys.com
Wed Jul 20 14:58:04 CEST 2011
Hello
I wanted to do a join query and instead of using the $query->statement()
[which does not help with paginate widget] I used QOM.
The query parser always uses the first selector specified in the
joinCondition for the propertyValue dynamic operand see [1] below. Is
there any workaround for this?
My code inside the tableArepository (with qomFactory injection) :
// prepare join of my_table_a and my_table_b
$left = $this->qomFactory->selector(NULL, 'my_table_a');
$right = $this->qomFactory->selector(NULL, 'my_table_b');
$joinCondition = $this->qomFactory->equiJoinCondition('my_table_a',
'uid', 'my_table_b', 'field1');
$source = $this->qomFactory->join(
$left,
$right,
Tx_Extbase_Persistence_QueryInterface::JCR_JOIN_TYPE_INNER,
$joinCondition
);
$query->setSource($source);
// Additional where clause
$query = $query->matching(
$this->qomFactory->comparison(
$this->qomFactory->propertyValue('field2', 'my_table_b'),
Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO, 123)
)
);
Expected query output: SELECT my_table_a.* FROM my_table_a INNER JOIN
my_table_b ON my_table_a.uid=my_table_b.field1 WHERE my_table_b.field2=123
Actual: SELECT my_table_a.* FROM my_table_a LEFT JOIN my_table_b ON
my_table_a.uid=my_table_b.field1 WHERE [1]*my_table_a*.field2=123
However I have soled my problem with doing a find on myTableB by
field2=123, get field1 in array and do find in uid of mytablea where uid
IN (array).
But I was interested in to know more about QOM.
Thanks,
Pankaj
--
With best regards,
Pankaj Lele
---------------------------
CTO & Executive Director
Lelesys Infotech Pvt. Ltd.
Pune/Goa, India
Web: http://www.lelesys.com
[Certified TYPO3 Integrator]
More information about the TYPO3-project-typo3v4mvc
mailing list