示例#1
0
 /**
  * Post single data record.
  *
  * Given a base query this method will return the single
  * data record with the given value of a unique key.
  *
  * @param  JDatabaseQuery  $query  A database query object.
  * @param  JTable          $table  The table to insert the data
  * @param  array           $data   The assoc array data
  *
  * @return mixed Exception if fail, true if ok.
  */
 public function postItem(JDatabaseQuery $query, $table, $data)
 {
     // Bind data to save content
     if (!$table->bind($data)) {
         throw new Exception($table->getError());
     }
     // Check the content
     //if (!$table->check()) {
     //	throw new Exception($table->getError());
     //}
     // Insert the content
     if (!$table->store()) {
         throw new Exception($table->getError());
     }
     return true;
 }
示例#2
0
 function save()
 {
     JRequest::checkToken() or jexit('Invalid Token');
     $record = JTable::getInstance('Status', 'Table');
     $post = JRequest::get('POST');
     $post['id'] = $post['id'] != 0 ? $post['id'] : false;
     if (!$record->save($post)) {
         // uh oh failed to save
         JError::raiseError('500', JTable::getError());
     }
     $this->setRedirect('index.php?option=com_jobboard&view=statuses&task=save', JText::_('COM_JOBBOARD_STATUS_SAVED'));
 }
 function apply()
 {
     JRequest::checkToken() or jexit('Invalid Token');
     $applicant = JRequest::get('POST');
     jimport('joomla.utilities.date');
     $now = new JDate();
     if ($applicant['job_id'] != 0) {
         $unsol_id = $applicant['id'];
         $applicant['id'] = false;
         $applicant['request_date'] = $now->toMySQL();
         $record =& JTable::getInstance('Applicant', 'Table');
         if (!$record->save($applicant)) {
             // uh oh failed to save
             JError::raiseError('500', JTable::getError());
         }
         $unsol =& JTable::getInstance('Unsolicited', 'Table');
         if (!$unsol->delete($unsol_id)) {
             // uh oh failed to delete
             JError::raiseError('500', JTable::getError());
         }
         $this->extendApply($applicant);
     } else {
         $applicant['last_updated'] = $now->toMySQL();
         $unsol_record =& JTable::getInstance('Unsolicited', 'Table');
         if (!$unsol_record->save($applicant)) {
             // uh oh failed to save
             JError::raiseError('500', JTable::getError());
         }
         $this->extendApply($applicant);
     }
 }