fixing model build script, using PDO inbuilt quote function for escaping, better null handling