Example #1
0
if (isset($_POST['set-norms'])) {
    // Check if this request is not dublicate (on refresh)
    if ($_POST['form_id'] === $mem->call('form_id')) {
        $data = $_POST;
        unset($data['form_id']);
        unset($data['set-norms']);
        $dset->putData($data);
    }
}
// ----------------------------------------------------------------------
// Corrections
if (isset($_POST['set-correction'])) {
    // Check if this request is not dublicate (on refresh)
    if ($_POST['form_id'] === $mem->call('form_id')) {
        $fields = array('year', 'quarter', 'person_id', 'correction');
        $pairs = array('year' => $_POST['year'], 'quarter' => $_POST['quarter'], 'person_id' => $_POST['person_id']);
        if ($db->checkIfRecordExists('corrections', $pairs)) {
            $sql = 'UPDATE `corrections` SET ' . Database::pdo_set($fields, $values, $_POST);
            $sql .= ' WHERE year=:year AND quarter=:quarter AND person_id=:person_id;';
        } else {
            $sql = 'INSERT INTO `corrections` ' . Database::insert_query($fields, $values, $POST) . ';';
        }
        $db->exec($sql, $values);
    }
}
// ----------------------------------------------------------------------
// Generate new random id to be used it the form (prevent dublicate POST)
$mem->store('form_id', md5(rand(0, 10000000)));
?>
 
Example #2
0
 /**
  *
  * @access  public
  * @param   array
  */
 public function addNewPerson($data)
 {
     $fields = array('firstname', 'lastname', 'position', 'email', 'phone', 'status');
     $sql = 'INSERT INTO `staff` ' . Database::insert_query($fields, $values, $data);
     $this->db->exec($sql, $values);
 }
Example #3
0
 /**
  * Sets a record into DB.
  *
  * @access  public
  * @param   array   data
  */
 public function addRecord($data)
 {
     $sql = 'INSERT INTO `results` ' . Database::insert_query($this->fields, $values, $data);
     $this->db->exec($sql, $values);
 }