Search code examples
typo3-flow

Why is this Repository Method not working?


I used this Repository Method in an Extbase Project and it worked fine.

public function findRandom() {
    $rows = $this->createQuery()->execute()->count();
    $row_number = mt_rand(0, max(0, ($rows - 1)));
    return $this->createQuery()->setOffset($row_number)->setLimit(1)->execute();
}

It is not working in TYPO3 Flow. Why? And what should I change?


Solution

  • I did not mention, the queryResult is not the object it self. Its an array. My code above is working.

    This is a difference between extbase and flow3. Flow3 returns an array. Extbase the object itself.