how can i make a database query with extbase to check if a database entry already exist? I know how to do that with php but not with extbase syntax.
I want to add a user to the database. That works. But the user should only be added if the regId doesn't already exist.
This is my code so far:
/**
* action registerDevice
* @param Tx_xxx_Domain_Repository_UserRepository $muserRepository
* @return void
*/
public function registerDeviceAction(){
$userRepository = $this->objectManager->get('Tx_xxx_Domain_Repository_UserRepository');
$user = $this->objectManager->create('Tx_xxx_Domain_Model_User');
$allUser = $this->userRepository->findAll();
if ( isset($_POST["regId"]) && $_GET['os'] ) {
$regDevice = $_POST["regId"];
$regMobileOs = $_GET["os"];
$user->setMobileOs( $regMobileOs );
$user->setFirstName('TEST');
$user->setRegId( $regDevice );
$this->userRepository->add($user);
$persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager');
$persistenceManager->persistAll();
}
}
Thank you very much! :)
Best regards