def find(self, searchData, result_limit=-1, orderData=[], full=False): """Make complex search. search_data = {name: (value, operator), ...} orderData = [(name, direction)] """ result = [] sql = 'SELECT * FROM ' + self._DATA_TABLE where = WhereHelper(searchData) sql += where.sql() orderby = "" # # TODO we need to move SQL code to parent class # for item in orderData: orderby += item[0] + " " + item[1] + "," orderby = orderby[:-1] if orderby: sql += " ORDER BY " + orderby sql += ' LIMIT ' + str(result_limit) try: for row in self._db.select(sql, where.values()): item = self.__class__() item._load_from_row(row, full) result.append(item) except DBException: msg = 'You performed an invalid search. Please verify your syntax.' raise DBException(msg) return result