'Construct instances of our class based on the given database query.
@yields One class instance for each row fetched.'

@classmethod
def fetch(cls, where='', params=(), joins='', order_by=''):

    order_by = cls._prefix_with(order_by, 'ORDER    BY    ')
    where = cls._prefix_with(where, 'WHERE    ')
    fields = [((cls._table_name + '.') + f) for f in cls._fields]
    query = ('SELECT    %(fields)s    FROM    %(table)s    %(joins)s    %(where)s    %(order_by)s' % {'fields': ',    '.join(fields), 'table': cls._table_name, 'joins': joins, 'where': where, 'order_by': order_by})
    rows = _db.execute(query, params)
    return [cls(id=row[0], row=row) for row in rows]
