findByFromStartToEnd

public function findByFromStartToEnd() {
	$query = $this->createQuery();
	$constraints = null;
	$constraints[] =  $query->equals('hidden', 0);
	$constraints[] =  $query->equals('deleted', 0);
	$constraints[] =  $query->lessThanOrEqual('start_date', date('Y-m-d'));
	$constraints[] =  $query->greaterThanOrEqual('end_date', date('Y-m-d'));
	return $query->matching(
		$query->logicalAnd( $constraints)
	)->execute();
}

Extbase FeUser Example Extension

GIT: https://github.com/wallpageNET/infochy_feuserexample
TER: https://typo3.org/extensions/repository/view/infochy_feuserexample

Model

    /**
     * user
     *
     * @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
     */
    protected $user;
    
    /**
     * Returns the user
     *
     * @return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $user
     */
    public function getUser() {
        return $this->user;
    }

    /**
     * Sets the user
     *
     * @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $user
     * @return void
     */
    public function setUser($user) {
        $this->user = $user;
    }

Controller

    /**
     * action create
     *
     * @param \Infochy\InfochyFeuserexample\Domain\Model\MyData $newMyData
     * @return void
     */
    public function createAction(\Infochy\InfochyFeuserexample\Domain\Model\MyData $newMyData)
    {
        $this->addFlashMessage('createAction ADD FrontendUser', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);       

		
	$newMyData->getUser()->addUsergroup($this->getFrontendUserGroup());          
        $this->myDataRepository->add($newMyData);
        $this->redirect('list');
    }
    
    private function getFrontendUserGroup(){
    	$frontendUserGroups = $this->frontendUserGroupRepository->findByTitle('InfochyFeuserexample');
		$frontendUserGroup = $frontendUserGroups->getFirst();
		if(!is_null($frontendUserGroup)){
			return $frontendUserGroup;
		}else{
			$frontendUserGroup = $this->objectManager->get('TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup');
			$frontendUserGroup->setTitle('InfochyFeuserexample');
			$frontendUserGroup->setDescription('Title display only on Sys-Pages');
			$this->frontendUserGroupRepository->add($frontendUserGroup);
			$persistenceManager =  $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager');
			$persistenceManager->persistAll();	
	    	$frontendUserGroups = $this->frontendUserGroupRepository->findByTitle('InfochyFeuserexample');
			return $frontendUserGroups->getFirst();					
		}
    }

Controller -> frontendUserGroupRepository

    /**
     * frontendUserGroupRepository
     *
     * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository
     * @inject
     */
    protected $frontendUserGroupRepository = NULL;

TCA

		'user' => array(
			'exclude' => 1,
			'label' => 'Fe User',
			'config' => array(
				'type' => 'inline',
				'foreign_table' => 'fe_users',
				'minitems' => 0,
				'maxitems' => 1,
				'appearance' => array(
					'collapseAll' => 0,
					'levelLinksPosition' => 'top',
					'showSynchronizationLink' => 1,
					'showPossibleLocalizationRecords' => 1,
					'showAllLocalizationLink' => 1
				),
			),
		),	

Fluid-HTML

<label for="user.username">
	FeUser->username
</label><br />
	<f:form.textfield property="user.username" /><br />
	
<label for="user.password">
	FeUser->password
</label><br />
	<f:form.textfield property="user.password" /><br />
	
<label for="user.name">
	FeUser->name
</label><br />
	<f:form.textfield property="user.name" /><br />
	
<label for="user.email">
	FeUser->email
</label><br />
	<f:form.textfield property="user.email" /><br />

findByUidsString (3,5,7)

public function findByUidsString($uids) {
    $uidArray = explode(",", $uids);
    $query = $this->createQuery();
    $query->getQuerySettings()->setRespectStoragePage(false);
    $query->matching(
        $query->in('uid', $uidArray),
        $query->logicalAnd(
            $query->equals('hidden', 0),
            $query->equals('deleted', 0)
        )
    );
    $query->setOrderings($this->orderByUidsString('uid', $uidArray)); 
    return $query->execute();
}
protected function orderByUidsString($field, $values) {
    $orderArray = array();
    foreach ($values as $value) {
        $orderArray["$field={$value}"] = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING;
    }
    return $orderArray;
}

executeSqlString

$query = $this->createQuery();    
$query->statement($sqlString);
$model = $query->execute();