Model find by attributes

Models now have a find_by_attributes method that searches for 1 match. This
function is escaped and safe to use. Requires an attributes parameter
that's a table with column names as keys.