orig_query = $str_criteria; $_queries = simbio_tokenizeCQL($str_criteria, $this->searchable_fields, $this->stop_words, $this->queries_word_num_allowed); // echo '
'; var_dump($_queries); echo ''; if (count($_queries) < 1) { return null; } // loop each query foreach ($_queries as $_num => $_query) { // field $_field = $_query['f']; // boolean if ($_title_buffer == '' && $_field != 'boolean') { $_sql_criteria .= " $_boolean "; } // break the loop if we meet `cql_end` field if ($_field == 'cql_end') { break; } // boolean mode $_b = isset($_query['b'])?$_query['b']:$_query; if ($_b == '*') { $_boolean = 'OR'; } else { $_boolean = 'AND'; } // search value $_q = @$this->obj_db->escape_string($_query['q']); // searched fields flag set $_searched_fields[$_field] = 1; $_previous_field = $_field; switch ($_field) { case 'location' : if (!$this->disable_item_data) { if ($_b == '-') { $_sql_criteria .= " biblio.location NOT LIKE '%$_q%'"; } else { $_sql_criteria .= " biblio.location LIKE '%$_q%'"; } } break; case 'colltype' : if (!$this->disable_item_data) { if ($_b == '-') { $_sql_criteria .= " biblio.collection_types NOT LIKE '%$_q%'"; } else { $_sql_criteria .= " biblio.collection_types NOT LIKE ($_subquery)"; } } break; case 'itemcode' : if (!$this->disable_item_data) { if ($_b == '-') { $_sql_criteria .= " biblio.items NOT LIKE '%$_q%'"; } else { $_sql_criteria .= " biblio.items LIKE '%$_q%'"; } } break; case 'callnumber' : if ($_b == '-') { $_sql_criteria .= ' biblio.call_number NOT LIKE \''.$_q.'%\''; } else { $_sql_criteria .= ' biblio.call_number LIKE \''.$_q.'%\''; } break; case 'itemcallnumber' : if (!$this->disable_item_data) { if ($_b == '-') { $_sql_criteria .= ' item.call_number NOT LIKE \''.$_q.'%\''; } else { $_sql_criteria .= ' item.call_number LIKE \''.$_q.'%\''; } } break; case 'class' : if ($_b == '-') { $_sql_criteria .= ' biblio.classification NOT LIKE \''.$_q.'%\''; } else { $_sql_criteria .= ' biblio.classification LIKE \''.$_q.'%\''; } break; case 'isbn' : if ($_b == '-') { $_sql_criteria .= ' biblio.isbn_issn!=\''.$_q.'\''; } else { $_sql_criteria .= ' biblio.isbn_issn=\''.$_q.'\''; } break; case 'publisher' : $_subquery = 'SELECT publisher_id FROM mst_publisher WHERE publisher_name LIKE \'%'.$_q.'%\''; if ($_b == '-') { $_sql_criteria .= " biblio.publisher_id NOT IN ($_subquery)"; } else { $_sql_criteria .= " biblio.publisher_id IN ($_subquery)"; } break; case 'publishyear' : if ($_b == '-') { $_sql_criteria .= ' biblio.publish_year!=\''.$_q.'\''; } else { $_sql_criteria .= ' biblio.publish_year=\''.$_q.'\''; } break; case 'gmd' : $_subquery = 'SELECT gmd_id FROM mst_gmd WHERE gmd_name=\''.$_q.'\''; if ($_b == '-') { $_sql_criteria .= " biblio.gmd_id NOT IN ($_subquery)"; } else { $_sql_criteria .= " biblio.gmd_id IN ($_subquery)"; } break; case 'notes' : $_q = isset($_query['is_phrase'])?'"'.$_q.'"':$_q; if ($_b == '-') { $_sql_criteria .= " NOT (MATCH (biblio.notes) AGAINST ('".$_q."' IN BOOLEAN MODE))"; } else { $_sql_criteria .= " (MATCH (biblio.notes) AGAINST ('".$_q."' IN BOOLEAN MODE))"; } break; } } // remove boolean's logic symbol prefix and suffix $_sql_criteria = preg_replace('@^(AND|OR|NOT)\s*|\s+(AND|OR|NOT)$@i', '', trim($_sql_criteria)); // below for debugging purpose only // echo "