Database query handler.

Checking of query type is more accurate, and returning multiple rows is
more efficient by using the PDO function, fetchAll.