Notice: Undefined index: => $this->db->escape($data['message'])

Не могу никак разобраться.

Дано: Страница поддержки типа Тикет системы. Всё вроде как работает хорошо, пока не хочу отредактировать данные "Билета", при редактировании.

Выходит ошибка "Notice: Undefined index: message in .../ticket.php on line 39" Плюсом удаляет все сообщения(message) в данной ветке.

Код в строке 39:

$this->db->query("INSERT INTO " . DB_PREFIX . "ticket_message SET ticket_id = '" . (int) $ticket_id . "', parent_id = '0', user_id = '" . (int) $this->user->getID() . "', message = '" . $this->db->escape($data['message']) . "', attach_file = '" . $this->db->escape(isset($data['attach_file']) ? json_encode($data['attach_file'], true) : json_encode(array(), true)) . "', date_added = NOW(), date_modified = NOW()");

Пробовал изменить на escape(isset($data['message'])) - вроде как ошибка не выдаётся и даёт всё редактировать, однако все Сообщение всё ещё удаляются.

Весь код данного блока:

public function editTicket($data, $ticket_id) {
    $this->db->query("UPDATE " . DB_PREFIX . "ticket_ticket SET department_id = '" . (int) $data['department_id'] . "', customer_id = '" . (int) $data['customer_id'] . "', priority_id = '" . (int) $data['priority_id'] . "', status_id = '" . (int) $data['status_id'] . "', user_id = '" . (int) $this->user->getID() . "', subject = '" . $this->db->escape($data['subject']) . "', name = '" . $this->db->escape($data['name']) . "', email = '" . $this->db->escape($data['email']) . "', form_field = '" . $this->db->escape(isset($data['form_field']) ? json_encode($data['form_field'], true) : '') . "', language_id = '" . (int) $data['language_id'] . "', date_added = NOW(), date_modified = NOW() WHERE ticket_id = '" . (int) $ticket_id . "'");

    $this->db->query("DELETE FROM " . DB_PREFIX . "ticket_message WHERE ticket_id = '" . (int) $ticket_id . "'");

    $this->db->query("INSERT INTO " . DB_PREFIX . "ticket_message SET ticket_id = '" . (int) $ticket_id . "', parent_id = '0', user_id = '" . (int) $this->user->getID() . "', message = '" . $this->db->escape(isset($data['message'])) . "', attach_file = '" . $this->db->escape(isset($data['attach_file']) ? json_encode($data['attach_file'], true) : json_encode(array(), true)) . "', date_added = NOW(), date_modified = NOW()");

    $this->db->query("DELETE FROM " . DB_PREFIX . "ticket_order WHERE ticket_id = '" . (int) $ticket_id . "'");

    if (isset($data['product'])) {
        foreach ($data['product'] as $order_id => $product) {
            $this->db->query("INSERT INTO " . DB_PREFIX . "ticket_order SET ticket_id = '" . (int) $ticket_id . "', order_id = '" . (int) $order_id . "', product = '" . $this->db->escape(json_encode($product, true)) . "'");
        }
    }
}

Разбил стоку на строки и, как и ожидалось ошибка выходит именно на $this->db->escape($data['message'])


Ответы (0 шт):