db_smartone = $this->load->database("onedev", true); } function get_booking_today() { if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $sql = "SELECT booking_today.* FROM booking_today WHERE BookingTodayIsActive = 'Y' ORDER BY BookingTodayID DESC LIMIT 1"; $query = $this->db_smartone->query($sql); if (!$query) { $this->db_smartone->trans_rollback(); $this->sys_error_db('select booking today error', $this->db_smartone); exit; } $row = $query->row_array(); $result = array("records" => $row); $this->sys_ok($result); } function update_booking() { if (!$this->isLogin) { $this->sys_error("Invalid Token"); exit; } $this->db_smartone->trans_begin(); $prm = $this->sys_input; $userId = $this->sys_user['M_UserID']; $bookingId = $prm["bookingId"]; $bookingDefault = $prm["bookingDefault"]; $sql = "UPDATE booking_today SET BookingTodayDefault = ?, BookingTodayLastUpdated = NOW(), BookingTodayUserID = ? WHERE BookingTodayID = ?"; $qry = $this->db_smartone->query($sql, [ $bookingDefault, $userId, $bookingId ]); if (!$qry) { $this->db_smartone->trans_rollback(); $this->sys_error_db("update booking today error", $this->db_smartone); exit; } $this->db_smartone->trans_commit(); $result = array( "total" => 1 ); $this->sys_ok($result); } }