2

How can I set up conditions to call mysql function from cakephp when there is no cakephp (from model) validation

code which call mysql function from controller :

$generateDocNum = $data_source->fetchAll("
select generateDocNum(?, ?, ?, ?, ?) as generateSn
", array(
'MNF',
$codeTelpArea, // city
$this->request->data['Manifest']['date'], // date
$codeBranch, //branch
$codeModa //Moda
));

The code running well, but the problem is that when the validation returns false (ex : notEmpty validation), the function has already been called. I just want to call that function when the validation is finished.

I have tried using

$this->Model->validationErrors

and

$this->Model->invalidFields()

but this isn't working at all.

James Webster
  • 31,873
  • 11
  • 70
  • 114
Kode Kite
  • 328
  • 5
  • 15

1 Answers1

0

have you tried calling function between

if ($this->Model->save()){
 //calling mysql function here
}
Onesinus Saut
  • 314
  • 5
  • 18
  • yes, I has already been tried using between it, but I need to set my field from return of mysql function which I've called – Kode Kite Aug 26 '16 at 09:50