Replace occurences of deprecated `db_query` API

Compliance with future MantisBT version 1.3; reduce risk of sql
injection attacks.

Fixes #79