public with sharing class CM_SearchOpportunity { public List results {get; private set;} public Boolean getIsOverLimit() { if (results != null && results.size() > 30) { return true; } return false; } public CM_SearchOpportunity() { this.results = new List(); } public void search() { // 検索条件を用意 String query = System.currentPageReference().getParameters().get('q'); String visitorPlaceId = System.currentPageReference().getParameters().get('r'); // 全角::をreplace query = query.replaceAll('::', '::'); if(query == null || query == '' || query.length() < 2) { return; } this.search(query, visitorPlaceId); } public void search(String query, String visitorPlaceId) { List qwords = new List(); List qwordstmp = query.split(' '); String nameCondition = ''; for (String qword : qwordstmp) { if (String.isBlank(qword) == false) { qwords.add('%' + String.escapeSingleQuotes(qword.replaceAll('%', '')) + '%'); nameCondition += ' Name like \'' + qwords[qwords.size() - 1] + '\' and'; } } String queryString = ''; // try{ queryString = ControllerUtil.getOppSearchSQOL(visitorPlaceId, nameCondition); // } // catch ( System.QueryException qe) { // this.results = new List(); // return; // } system.debug('queryString=' + queryString); if(queryString == null || queryString == ''){ return; } this.results = (List) Database.query(queryString); } }