prefix . 'dpsupport_attachments'; } public function add( $ticket_id, $message_id, $attachment_id ) { global $wpdb; $ok = $wpdb->insert( $this->table(), array( 'ticket_id' => absint( $ticket_id ), 'message_id' => absint( $message_id ), 'attachment_id' => absint( $attachment_id ), 'created_at' => current_time( 'mysql' ), ), array( '%d', '%d', '%d', '%s' ) ); return false !== $ok; } public function get_for_ticket( $ticket_id ) { global $wpdb; return $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %i WHERE ticket_id = %d ORDER BY id ASC', $this->table(), absint( $ticket_id ) ) ); } public function get_attachment_ids_for_ticket( $ticket_id ) { global $wpdb; return array_map( 'absint', $wpdb->get_col( $wpdb->prepare( 'SELECT DISTINCT attachment_id FROM %i WHERE ticket_id = %d', $this->table(), absint( $ticket_id ) ) ) ); } } // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching