/**
  * Add trainer to training session
  */
 public static function addTrainerToTraining($trainer_id, $training_id, $duration_days)
 {
     $tableObj = new TrainingToTrainer();
     $select = $tableObj->select()->from($tableObj->_name, array('doesExist' => 'COUNT(*)'))->setIntegrityCheck(false)->where("trainer_id = {$trainer_id} AND training_id = {$training_id}");
     $row = $tableObj->fetchRow($select);
     if ($row->doesExist) {
         return -1;
     } else {
         $data['trainer_id'] = $trainer_id;
         $data['training_id'] = $training_id;
         $data['duration_days'] = $duration_days;
         try {
             return $tableObj->insert($data);
         } catch (Zend_Exception $e) {
             error_log($e);
         }
     }
 }
Exemplo n.º 2
0
 public static function isReferenced($id)
 {
     require_once 'PersonToTraining.php';
     $participant = new PersonToTraining();
     $select = $participant->select();
     $select->where("person_id = ?", $id);
     if ($participant->fetchRow($select)) {
         return true;
     }
     require_once 'TrainingToTrainer.php';
     $trainer = new TrainingToTrainer();
     $select = $trainer->select();
     $select->where("trainer_id = ?", $id);
     if ($trainer->fetchRow($select)) {
         return true;
     }
     return false;
 }