Snippets

This Mächler TYPO3 Extbase Repository - Query with limit and condition

Created by This Mächler
/**
 * The repository for Dates
 */
class DateRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
	protected $defaultOrderings = array(
		'date_time' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
	);	
		
	public function findUpcoming( $count ){
	  $now = new \DateTime();
	  $query = $this->createQuery();
	  $query 
	    ->setLimit( $count )
	    ->matching(
	      $query->greaterThanOrEqual('date_time', $now)
	    );
	  return $query->execute();
	}
	
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.