Code cleanup

- simply to highlight code is now using PDO (easy transition to mysql?)
- test-api.sh updated to new API change (still usable in debug mode)
- all db queries are prepared (solves naughty input issues)