move all db function to include/db.inc from patterns_server.module