示例#1
0
 public function set_medical()
 {
     if (parent::connection()) {
         /*
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Array
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     (
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [hospital] => 6
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [typeofmedical] => 9999
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [organ] => ไส้ติ่งขาด
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [date_start] => 2015-11-05
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [date_end] => 2015-11-06
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [cost] => 18900
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [amountofmedicine] => 2
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [medicine_1] => 1A 656/2531
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     [medicine_2] => A656T43
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     )
         */
         $sql = "INSERT INTO `medical`(`medical_id`, `organ`, `cost`, `date_start`, `date_end`, `rating`, `hospital_id`, `profile_id`, `medical_type_id`, `date_added`, `comment`)\n                VALUES (NULL,?,?,?,?,?,?,?,?,NOW(),?)";
         if ($stmt = $this->mysqli->prepare($sql)) {
             $stmt->bind_param('sisssisis', $this->medical_detail['organ'], $this->medical_detail['cost'], $this->medical_detail['date_start'], $this->medical_detail['date_end'], $this->medical_detail['rating'], $this->medical_detail['hospital'], $_SESSION['profile_detail']['profile_username'], $this->medical_detail['typeofmedical'], $this->medical_detail['comment']);
             $stmt->execute();
             if ($stmt->affected_rows) {
                 $insert_id = $stmt->insert_id;
                 $stmt->close();
                 if (!$this->set_medicine_order($insert_id)) {
                     return false;
                 }
                 if (!$this->set_rating()) {
                     return false;
                 }
                 parent::close_connection();
                 return true;
             } else {
                 print "Create medical error: " . $stmt->error;
             }
         } else {
             print "Prepare medical error: " . $this->mysqli->error;
         }
     }
 }
示例#2
0
 public function set()
 {
     /*
             Array
             (
             [username] => panchai
             [password] => 489329
             [title] => นาย
             [firstname] => พันชัย
             [lastname] => ประสมเพชร
             [birthday] => 1988-12-21
             [tel] => 0875435550
             [email] => thongtank@hotmail.com
             [address] => 213 หมู่ 12
             [province] => 23
             [amphur] => 325
             [district] => 2947
             [zipcode] => 34140
             [lat] =>
             [lng] =>
     
             )
     */
     $age = $this->get_age();
     $gender = "M";
     if ($this->pf['title'] == 'นางสาว' || $this->pf['title'] == 'นาง') {
         $gender = "F";
     }
     $sql = "INSERT INTO `profile`(`profile_username`, `profile_pwd`, `firstname`, `lastname`, `age`, `title`, `gender`, `birthday`, `tel`, `email`, `address`, `province`, `amphur`, `district`, `zipcode`, `lat`, `lng`, `date_added`)\n            VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())";
     if (parent::connection()) {
         if ($stmt = $this->mysqli->prepare($sql)) {
             $stmt->bind_param('ssssissssssiiiiss', $this->pf['username'], $this->pf['password'], $this->pf['firstname'], $this->pf['lastname'], $age, $this->pf['title'], $gender, $this->pf['birthday'], $this->pf['tel'], $this->pf['email'], $this->pf['address'], $this->pf['province'], $this->pf['amphur'], $this->pf['district'], $this->pf['zipcode'], $this->pf['lat'], $this->pf['lng']);
             $stmt->execute();
             if ($stmt->affected_rows) {
                 $stmt->close();
                 parent::close_connection();
                 return true;
             } else {
                 echo $stmt->error;
                 return false;
             }
         } else {
             echo $this->mysqli->error;
         }
     }
 }