Add sql features to getList

Add sql, sort order and page offset params to getList method in db.php.