fix some warning and implement the query function in the DB class