Example #1
0
 /**
  *
  * @access  public
  * @param   array
  */
 public function editPerson($data)
 {
     $fields = array('firstname', 'lastname', 'position', 'email', 'phone', 'status');
     $sql = 'UPDATE `staff` SET' . Database::pdo_set($fields, $values, $data) . ' WHERE id=:id;';
     $values['id'] = $data['id'];
     $this->db->exec($sql, $values);
 }
Example #2
0
 /**
  * Inserts new orders data to DB and return order number.
  *
  * @access  public
  * @param   string  total money of the order
  * @param   array   items in the order
  * @return  string
  */
 public function createNewOrder($amount, $items = array())
 {
     // These are names of the DB fields
     $fields = array('amount', 'payment', 'firstname', 'lastname', 'phone', 'email', 'address', 'comment', 'status', 'items');
     // Some of the order data we know...
     $source = array('amount' => $amount, 'status' => 'pending', 'items' => serialize($items));
     // ... some have to take from POST
     $source = array_merge($source, $_POST);
     $sql = 'INSERT INTO orders SET ' . Database::pdo_set($fields, $values, $source);
     // Log the order content
     foreach ($values as $k => $v) {
         self::log($k . '=' . $v);
     }
     $this->db->exec($sql, $values);
     $o_id = $this->db->lastInsertId();
     return self::convertIdToNumber($o_id);
 }
Example #3
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 #4
0
 public function logTransaction()
 {
     // These POST vars are needed to DB insert
     $fields = array('ORDER', 'AMOUNT', 'TIMESTAMP', 'TRTYPE', 'RESULT', 'RC', 'RCTEXT', 'AUTHCODE', 'RRN', 'INT_REF', 'NAME', 'CARD');
     $sql = 'INSERT INTO transactions SET ' . Database::pdo_set($fields, $values);
     $this->db->exec($sql, $values);
     return $this->db->lastInsertId();
 }
Example #5
0
 /**
  * Update the record into DB.
  *
  * @access  public
  * @param   array   data
  */
 public function editRecord($data)
 {
     $sql = 'UPDATE `results` SET ' . Database::pdo_set($this->fields, $values, $data) . ' WHERE id=:id;';
     $this->db->exec($sql, $values);
 }