[TYPO3-english] Re: run a simple query to check for existence of a value
Calgacus map Brude
calgach at gmail.com
Thu Nov 14 22:59:38 CET 2013
here is what I finally got to work:
in my repo
public function findCouponByBarcode($code) {
$query = $this->createQuery();
$query->matching($query->like('barcode',$code) );
$ret = $query->execute();
return $ret
}
and in my controller:
$barcode = '123123123';//example
$coupon = $this->couponRepository->findCouponByBarcode($barcode);
if ( $coupon != null ) {
foreach($coupon as $result) {
if(time() > strtotime($result->getExpiry())) {
$this->flashMessageContainer->add('That Coupon is expired.' );
$this->redirect('validate_failed');
} else {
$this->flashMessageContainer->add('Valid.' );
$this->redirect('validate_success');
}
}
}
$this->flashMessageContainer->add('Not valid. Coupon code does not exist.' );
$this->redirect('validate_failed');
More information about the TYPO3-english
mailing list