CakePHP: Models in AppController -


i've created function in appcontroller sendemails:

protected function sendemail($studentid = null, $courseid = null, $action = null) {      $course = $this->course->find('first', array('conditions' => array('course.id' => $courseid)));     if(! $course) {         throw new notfoundexception(__('invalid course'));     } } 

i want verify course , student, depending on controller call from, have modify $this->xxx->find statement. other solution i've came validating/sending $course/$student data head of time, i'd still run manual sql query save email log (i'd run same problem). help?

i don't understand problem, but:

if it's ok, or not, tel me.. come new ideea based on code. don't database structure, think works join query...

$course = $this->course $student = $this->student   if(!empty($student) && !empty($course)): $status = 3 endif;      if(empty($student)): $status1 = 1 else: $status = 0 endif;   if(empty($course)): $status2 = 2 else: $status = 0 endif;     if(empty($status)):       $array=array($status1,status2);     else:       $array=array($status);     endif;         foreach($array $key => $value)         if($value == 1):throw new notfoundexception(__('invalid course'));          if($value == 2):throw new notfoundexception(__('invalid student'));         if($value == 0):throw new notfoundexception(__('invalid course , student'));          if($value == 3):throw new notfoundexception(__('valide course , student'));        endforeach; 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -