db->query($query); return $query->result_array(); } public function checkIsMember($member_type, $id) { $this->db->select()->from('libarary_members'); $this->db->where('libarary_members.member_id', $id); $this->db->where('libarary_members.member_type', $member_type); $query = $this->db->get(); $result = $query->num_rows(); if ($result > 0) { $row = $query->row(); $book_lists = $this->bookissue_model->book_issuedByMemberID($row->id); return $book_lists; } else { return false; } } public function getByMemberID($id = null) { $this->db->select()->from('libarary_members'); if ($id != null) { $this->db->where('libarary_members.id', $id); } $query = $this->db->get(); if ($id != null) { $result = $query->row(); if ($result->member_type == "student") { $return = $this->getStudentData($result->id); } else { $return = $this->getTeacherData($result->id); } return $return; } } function getTeacherData($id) { $this->db->select('libarary_members.id as `lib_member_id`,libarary_members.library_card_no,libarary_members.member_type,staff.*'); $this->db->from('libarary_members'); $this->db->join('staff', 'libarary_members.member_id = staff.id'); $this->db->where('libarary_members.id', $id); $query = $this->db->get(); $result = $query->row(); return $result; } function getStudentData($id) { $this->db->select('libarary_members.id as `lib_member_id`,libarary_members.library_card_no,libarary_members.member_type,students.*'); $this->db->from('libarary_members'); $this->db->join('students', 'libarary_members.member_id = students.id'); $this->db->where('libarary_members.id', $id); $query = $this->db->get(); $result = $query->row(); return $result; } function surrender($id) { $this->db->trans_start(); # Starting Transaction $this->db->trans_strict(false); # See Note 01. If you wish can remove as well //=======================Code Start=========================== $this->db->where('id', $id); $this->db->delete('libarary_members'); $message = DELETE_RECORD_CONSTANT . " On libarary members id " . $id; $action = "Delete"; $record_id = $id; $this->log($message, $record_id, $action); $this->db->where('member_id', $id); $this->db->delete('book_issues'); $message = DELETE_RECORD_CONSTANT . " On book issues id " . $id; $action = "Delete"; $record_id = $id; $this->log($message, $record_id, $action); //======================Code End============================== $this->db->trans_complete(); # Completing transaction /* Optional */ if ($this->db->trans_status() === false) { # Something went wrong. $this->db->trans_rollback(); return false; } else { return true; } } }