Remove direct mysqli use

Generic DB rework:

- replaces mysqli use with PDO hardcoded to mysql. The idea is to eventually support other DBMS, too.
- unify database schema handling in system/includes/db_updates.php. See commit message for details.

There are some more bits hidden in there: removed some gettype() calls (replaced with is_string, as recommended by the docs), start to use prepared statements and bound parameters, instead of manual string escaping.