Example #1
0
 public function get_by_id($id)
 {
     $user = null;
     //DATABASE CONNECTION
     $this->db->connect();
     //SELECT BY ID
     $sql = "SELECT * FROM user WHERE user_id=?";
     //PREPARE
     $stmt = $this->db->initialize($sql);
     //BIND
     $stmt->bind_param("i", $id);
     //EXECUTE
     $stmt->execute();
     //BIND RESULT
     $stmt->bind_result($user_id, $user_name, $first_name, $last_name, $contact_number, $user_type, $user_status);
     while ($stmt->fetch()) {
         //instantiate object
         $user = new User();
         $user->set_user_id($user_id);
         $user->set_user_name($user_name);
         $user->set_first_name($first_name);
         $user->set_last_name($last_name);
         $user->set_contact_number($contact_number);
         $user->set_user_type($user_type);
         $user->set_user_status($user_status);
     }
     $this->db->close();
     return $user;
 }
 public function get_all()
 {
     //ARRAY OBJECT HARU PASS GARNA
     $user_list = array();
     //DATABASE CONNECTION
     $this->db->connect();
     //SELECT ALL QUERY
     $sql = "SELECT user_id,user_name,first_name,last_name,contact_number,user_type,user_status,gen_id,age FROM user INNER JOIN generaluser ON user_id = u_id";
     //fetchquery
     $result = $this->db->fetchquery($sql);
     //STORE IN OBJECT AND SEND TO VIEW
     while ($row = $result->fetch_assoc()) {
         $user = new User();
         $user->set_user_id($row['user_id']);
         $user->set_user_name($row['user_name']);
         $user->set_first_name($row['first_name']);
         $user->set_last_name($row['last_name']);
         $user->set_contact_number($row['contact_number']);
         $user->set_user_type($row['user_type']);
         $user->set_user_status($row['user_status']);
         array_push($user_list, $user);
     }
     $this->db->close();
     return $user_list;
 }
 public function get_all()
 {
     //ARRAY OBJECT HARU PASS GARNA
     $user_list = array();
     //DATABASE CONNECTION
     $this->db->connect();
     //SELECT ALL QUERY
     $sql = "SELECT user_id,user_name,first_name,last_name,contact_number,user_type,user_status,name,doe,img,address,service,objective FROM user INNER JOIN welfare ON user_id = u_id";
     //fetchquery
     $result = $this->db->fetchquery($sql);
     //STORE IN OBJECT AND SEND TO VIEW
     while ($row = $result->fetch_assoc()) {
         $user = new User();
         $user->set_user_id($row['user_id']);
         $user->set_user_name($row['user_name']);
         $user->set_first_name($row['first_name']);
         $user->set_last_name($row['last_name']);
         $user->set_contact_number($row['contact_number']);
         $user->set_user_type($row['user_type']);
         $user->set_user_status($row['user_status']);
         $user->set_welf_name($row['name']);
         $user->set_welf_doe($row['doe']);
         $user->set_welf_img($row['img']);
         $user->set_welf_address($row['address']);
         $user->set_welf_objective($row['objective']);
         $user->set_welf_service($row['service']);
         array_push($user_list, $user);
     }
     $this->db->close();
     return $user_list;
 }
Example #4
0
 private function _map_posted_data()
 {
     $user = new User();
     $user->set_user_name($_POST['user_name']);
     $user->set_first_name($_POST['first_name']);
     $user->set_last_name($_POST['last_name']);
     $user->set_contact_number($_POST['contact_number']);
     $user->set_user_type($_POST['user_type']);
     $user->set_user_status($_POST['user_status']);
     return $user;
 }
Example #5
0
 private function _map_posted_data()
 {
     $user = new User();
     $user->set_user_name($_POST['user_name']);
     $user->set_first_name($_POST['first_name']);
     $user->set_last_name($_POST['last_name']);
     $user->set_contact_number($_POST['contact_number']);
     if (isset($_POST['user_type'])) {
         $user->set_user_type($_POST['user_type']);
     }
     $user->set_user_status($_POST['user_status']);
     if (isset($_POST['password'])) {
         $user->set_password($_POST['password']);
     }
     if ($_POST['user_type'] == 'organization') {
         $user->set_name($_POST['name']);
         $user->set_doe($_POST['doe']);
         $user->set_address($_POST['address']);
         $user->set_objective($_POST['objective']);
         //store file
         $filename = $_FILES['img']['name'];
         $path = PUBLIC_PATH . "/pictures/orgPictures/";
         move_uploaded_file($_FILES['img']['tmp_name'], $path . $filename);
         $savepath = PUBLIC_PATH2 . "/pictures/orgPictures/";
         $user->set_img($savepath . $filename);
     } elseif ($_POST['user_type'] == 'welfare') {
         $user->set_welf_name($_POST['welf_name']);
         $user->set_welf_doe($_POST['welf_doe']);
         $user->set_welf_service($_POST['welf_service']);
         $user->set_welf_address($_POST['welf_address']);
         $user->set_welf_objective($_POST['welf_objective']);
         //store file
         $filename = $_FILES['img']['name'];
         $path = PUBLIC_PATH . "/pictures/welfPictures/";
         move_uploaded_file($_FILES['img']['tmp_name'], $path . $filename);
         $savepath = PUBLIC_PATH2 . "/pictures/welfPictures/";
         $user->set_welf_img($savepath . $filename);
     }
     return $user;
 }