Generating code for db-to-php type/value conversion to speed things up