Rewriting the database code

Now includes a simple query builder. Almost every page has to be
modified.
Database now extends PDO

The classes in the repository package can now use any PDO instance, not
just Database.
Fix widget editing being broken by 774a629857888d8cd056949c30185b7eb17f4816
Fix comment editing links being broken by 774a629857888d8cd056949c30185b7eb17f4816
Merge remote-tracking branch 'origin/database'