if (count($where)) {
            $query .= " WHERE " . implode(" AND ", $where);
        }