Mikael
Mikael

Reputation: 1309

TYPO3 query equals by another table

I have TYPO3 7.6.18, and I have problem with query.

this works

public function getFiltered($offset = 0, $limit = 5){
    $query = $this->createQuery();
    $query->matching($query->equals('cruserId', 3));
    return $query->execute();

But this not works

public function getFiltered($offset = 0, $limit = 5){
    $query = $this->createQuery();
    $query->matching($query->equals('cruserId.uid', 3));

    return $query->execute();

this return empty. Why? I filter by condition in another table(fe_users). I need filter by uid, gender or other fields. I don't know where is a problem.

TCA:

'cruser_id' => [
    'exclude' => 1,
    'label' => 'LLL:EXT:fefiles/Resources/Private/Language/locallang_db.xlf:tx_fefiles_domain_model_photo.cruser_id',
    'config' => [
        'type' => 'inline',
        'foreign_table' => 'fe_users',
        'minitems' => 0,
        'maxitems' => 1,
        'appearance' => [
            'collapseAll' => 0,
            'levelLinksPosition' => 'top',
            'showSynchronizationLink' => 1,
            'showPossibleLocalizationRecords' => 1,
            'showAllLocalizationLink' => 1
        ],
    ]
],

Model:

  /**
     * CruserId
     *
     * @var \Fhk\Feusersplus\Domain\Model\User
     * @inject
     */
    protected $cruserId;

    /**
     * Returns the cruserId
     *
     * @return \Fhk\Feusersplus\Domain\Model\User $cruserId
     */
    public function getCruserId()
    {
        return $this->cruserId;
    }

    /**
     * Sets the cruserId
     *
     * @return void
     */
    public function setCruserId($cruserId)
    {
        $this->cruserId = $cruserId;
    }

If I use cruserId.uid - it just return empty. I had specially create test ext by extension builder and make my model, tca the same, but it return empty. Help me please, good people) Do you now where is problem?

Upvotes: 0

Views: 271

Answers (2)

Mikael
Mikael

Reputation: 1309

$query->getQuerySettings()->setRespectStoragePage(false);
        $query->getQuerySettings()->setRespectSysLanguage(false);

this solved my problem

Upvotes: 0

Pravin Vavadiya
Pravin Vavadiya

Reputation: 3207

I think cruserId.uid is not your Tables fields. in TYPO3 Extabase query syntax you need to pass always feilds name like.

$query->equals($propertyName, $operand, $caseSensitive = true )

Parameters

  • string $propertyName The name of the property to compare against
  • mixed $operand The value to compare with
  • bool $caseSensitive Whether the equality test should be done case-sensitive

For more infromation TYPO3 Query syntax

Upvotes: 1

Related Questions