UrunController.php
public function kontrolAction(){
$kk = new urunler();
$kk->kodkontrol($this->request->getPost());
echo $kk;
}
urunler.php
public function kodkontrol(){
while(1){
$UrunKodu = chr(rand(65,90)).chr(rand(65,90)).'-'.rand(1,9999);
$UKKontrol = $this->findFirst("urunBarkod = '{$UrunKodu}'");
if($UKKontrol > 0){
continue;
} else{
break;
}
}
echo $UrunKodu;
}