Whitespace formatting
Fix the SQL escaping style to use PDO's approach

Per #253.
Fix a bug that slowed down paragraph iteration
Fix bug in how section hierarchies are established
Require a literal 0 rows in response to a PDO query
Remove debugging line
Use a better error message
Small changes to error logging
Overhaul the code-export functionality

Improvements to #280, but also to further progress towards #161.