[TYPO3-mvc] How can I "add" some constraints to an existing query

Michael Knoll mimi at kaktusteam.de
Sun Mar 6 13:21:43 CET 2011


When I try

$extbaseQuery->matching($extbaseQuery->logicalAnd($extbaseQuery->getConstraint(), 
$extbaseQuery->equals('deleted', 0)));

What would make perfect sense for me, I get the following query:

"SELECT tx_yag_domain_model_album.* FROM tx_yag_domain_model_album WHERE 
(1<>1 AND tx_yag_domain_model_album.deleted = '0') AND 
tx_yag_domain_model_album.sys_language_uid IN (0,-1) LIMIT 15"

When I do not add an additional constraint, I get the following query:

"SELECT  tx_yag_domain_model_album.* FROM tx_yag_domain_model_album 
WHERE tx_yag_domain_model_album.uid IN ('2') AND 
tx_yag_domain_model_album.deleted=0 AND 
tx_yag_domain_model_album.hidden=0 AND 
tx_yag_domain_model_album.sys_language_uid IN (0,-1) LIMIT 15"

So the part that is missing is "WHERE tx_yag_domain_model_album.uid IN 
('2')"


Any ideas?

Thanks a lot

Mimi



Am 06.03.11 13:15, schrieb Michael Knoll:
> Hi there,
>
> I would like to add some constraints to an existing query. As I have
> enableFields turned off for the query, I would like to add deleted='0'
> to disable deleted records. What I did is the following:
>
> if ($respectEnableFields == '0') {
> // We turn off enable fields (hidden and deleted)
> $extbaseQuery->getQuerySettings()->setRespectEnableFields(FALSE);
> if ($respectHiddenField == '1') {
> // Turn on usage of hidden fields --> show records with hidden = 0
> $extbaseQuery->matching($extbaseQuery->logicalAnd(
> $extbaseQuery->equals('hidden', 0)));
> }
> if ($respectDeletedField == '1') {
> // Turn on usage of deleted field --> show records with deleted = 0
> $extbaseQuery->matching($extbaseQuery->logicalAnd(
> $extbaseQuery->equals('deleted', 0)));
> }
> }
>
>
> But this does not preserve any constraints existing in my query... How
> can I achieve "adding" the deleted- or hidden-constraint to an existing
> query?
>
>
> Thanks a lot!
>
> Greetings
>
> Mimi



More information about the TYPO3-project-typo3v4mvc mailing list