本文整理汇总了PHP中ca_metadata_elements::getFieldValuesArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_metadata_elements::getFieldValuesArray方法的具体用法?PHP ca_metadata_elements::getFieldValuesArray怎么用?PHP ca_metadata_elements::getFieldValuesArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_metadata_elements
的用法示例。
在下文中一共展示了ca_metadata_elements::getFieldValuesArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _doQueriesForSqlSearch
//.........这里部分代码省略.........
if (!is_numeric($vs_term)) {
$vb_all_numbers = false;
break;
}
}
$vs_raw_term = join(' ', $va_raw_terms);
$vb_exact = $vs_raw_term[0] == "#" ? true : false;
// dates prepended by "#" are considered "exact" or "contained - the matched dates must be wholly contained by the search term
if ($vb_exact) {
$vs_raw_term = substr($vs_raw_term, 1);
if ($this->opo_tep->parse($vs_raw_term)) {
$va_dates = $this->opo_tep->getHistoricTimestamps();
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 BETWEEN " . floatval($va_dates['start']) . " AND " . floatval($va_dates['end']) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal2 BETWEEN " . floatval($va_dates['start']) . " AND " . floatval($va_dates['end']) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
}
} else {
if ($this->opo_tep->parse($vs_raw_term)) {
$va_dates = $this->opo_tep->getHistoricTimestamps();
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 BETWEEN " . floatval($va_dates['start']) . " AND " . floatval($va_dates['end']) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal2 BETWEEN " . floatval($va_dates['start']) . " AND " . floatval($va_dates['end']) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 <= " . floatval($va_dates['start']) . " AND cav.value_decimal2 >= " . floatval($va_dates['end']) . ")\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
}
}
break;
case 4:
// geocode
$t_geocode = new GeocodeAttributeValue();
// If it looks like a lat/long pair that has been tokenized by Lucene
// into oblivion rehydrate it here.
if ($va_coords = caParseGISSearch(join(' ', $va_raw_terms))) {
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 BETWEEN {$va_coords['min_latitude']} AND {$va_coords['max_latitude']})\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal2 BETWEEN {$va_coords['min_longitude']} AND {$va_coords['max_longitude']})\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
}
break;
case 6:
// currency
$t_cur = new CurrencyAttributeValue();
$va_parsed_value = $t_cur->parseValue(join(' ', $va_raw_terms), $t_element->getFieldValuesArray());
$vn_amount = $va_parsed_value['value_decimal1'];
$vs_currency = preg_replace('![^A-Z0-9]+!', '', $va_parsed_value['value_longtext1']);
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 = " . floatval($vn_amount) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_longtext1 = '" . $this->opo_db->escape($vs_currency) . "')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
break;
case 8:
// length
$t_len = new LengthAttributeValue();
$va_parsed_value = $t_len->parseValue(array_shift($va_raw_terms), $t_element->getFieldValuesArray());
$vn_len = $va_parsed_value['value_decimal1'];
// this is always in meters so we can compare this value to the one in the database
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 = " . floatval($vn_len) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
break;
case 9:
// weight
$t_weight = new WeightAttributeValue();
$va_parsed_value = $t_weight->parseValue(array_shift($va_raw_terms), $t_element->getFieldValuesArray());
$vn_weight = $va_parsed_value['value_decimal1'];
// this is always in kilograms so we can compare this value to the one in the database
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 = " . floatval($vn_weight) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
break;
case 10:
// timecode
$t_timecode = new TimecodeAttributeValue();
$va_parsed_value = $t_timecode->parseValue(join(' ', $va_raw_terms), $t_element->getFieldValuesArray());
$vn_timecode = $va_parsed_value['value_decimal1'];
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 = " . floatval($vn_timecode) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
break;
case 11:
// integer
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_integer1 = " . intval(array_shift($va_raw_terms)) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
break;
case 12:
示例2: search
//.........这里部分代码省略.........
// This allows us to do "intelligent" querying... for example on date ranges
// parsed from natural language input and for length dimensions using unit conversion
//
switch ($t_element->get('datatype')) {
case 2:
// dates
$vb_exact = $vs_term[0] == "#" ? true : false;
// dates prepended by "#" are considered "exact" or "contained - the matched dates must be wholly contained by the search term
if ($vb_exact) {
$vs_raw_term = substr($vs_term, 1);
if ($this->opo_tep->parse($vs_term)) {
$va_dates = $this->opo_tep->getHistoricTimestamps();
// TODO: fix date handling to reflect distinctions in ranges
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_table . '.' . $vs_fld_num));
}
} else {
if ($this->opo_tep->parse($vs_term)) {
$va_dates = $this->opo_tep->getHistoricTimestamps();
// TODO: fix date handling to reflect distinctions in ranges
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_table . '.' . $vs_fld_num));
}
}
break;
case 4:
// geocode
$t_geocode = new GeocodeAttributeValue();
if ($va_coords = caParseGISSearch($vs_term)) {
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $va_coords['min_latitude'] . ',' . $va_coords['min_longitude'] . " TO " . $va_coords['max_latitude'] . ',' . $va_coords['max_longitude'] . ']', $vs_table . '.' . $vs_fld_num));
}
break;
case 6:
// currency
$t_cur = new CurrencyAttributeValue();
$va_parsed_value = $t_cur->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_amount = (double) $va_parsed_value['value_decimal1'];
$vs_currency = preg_replace('![^A-Z0-9]+!', '', $va_parsed_value['value_longtext1']);
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_amount, $vs_table . '.' . $vs_fld_num));
break;
case 8:
// length
$t_len = new LengthAttributeValue();
$va_parsed_value = $t_len->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_len = (double) $va_parsed_value['value_decimal1'];
// this is always in meters so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_len, $vs_table . '.' . $vs_fld_num));
break;
case 9:
// weight
$t_weight = new WeightAttributeValue();
$va_parsed_value = $t_weight->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_weight = (double) $va_parsed_value['value_decimal1'];
// this is always in kilograms so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_weight, $vs_table . '.' . $vs_fld_num));
break;
case 10:
// timecode
$t_timecode = new TimecodeAttributeValue();
$va_parsed_value = $t_timecode->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_timecode = (double) $va_parsed_value['value_decimal1'];
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_timecode, $vs_table . '.' . $vs_fld_num));
break;
case 11:
// integer
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term((double) $vs_term, $vs_table . '.' . $vs_fld_num));
break;
case 12:
示例3: execute
//.........这里部分代码省略.........
$qr_res = $this->opo_db->query($vs_sql, (string) $vn_row_id);
} else {
$vs_sql = "\n\t\t\t\t\t\t\t\t\t\t\t\tSELECT " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->ops_browse_table_name . "\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_relative_to_join}\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t({$vs_table_name}.{$vs_field_name} = ?)";
$qr_res = $this->opo_db->query($vs_sql, (string) $vn_row_id);
}
$va_acc[$vn_i] = $qr_res->getAllFieldValues($this->ops_browse_table_name . '.' . $t_item->primaryKey());
$vn_i++;
}
break;
# -----------------------------------------------------
# -----------------------------------------------------
case 'attribute':
$t_element = new ca_metadata_elements();
if (!$t_element->load(array('element_code' => $va_facet_info['element_code']))) {
return array();
}
$vn_datatype = $t_element->get('datatype');
if ($va_facet_info['relative_to']) {
if ($va_relative_execute_sql_data = $this->_getRelativeExecuteSQLData($va_facet_info['relative_to'], $pa_options)) {
$va_relative_to_join = $va_relative_execute_sql_data['relative_joins'];
$vs_relative_to_join = join("\n", $va_relative_to_join);
$vs_target_browse_table_name = $va_relative_execute_sql_data['target_table_name'];
$vs_target_browse_table_num = $va_relative_execute_sql_data['target_table_num'];
$vs_target_browse_table_pk = $va_relative_execute_sql_data['target_table_pk'];
}
}
// TODO: check that it is a *single-value* (ie. no hierarchical ca_metadata_elements) Text or Number attribute
// (do we support other types as well?)
$vn_element_id = $t_element->getPrimaryKey();
$o_attr = Attribute::getValueInstance($vn_datatype);
foreach ($va_row_ids as $vn_row_id) {
$vn_row_id = urldecode($vn_row_id);
$vn_row_id = str_replace('/', '/', $vn_row_id);
$va_value = $o_attr->parseValue($vn_row_id, $t_element->getFieldValuesArray());
$va_attr_sql = array();
$va_attr_values = array(intval($vs_target_browse_table_num), $vn_element_id);
if (is_array($va_value)) {
foreach ($va_value as $vs_f => $vs_v) {
if ($vn_datatype == __CA_ATTRIBUTE_VALUE_LIST__) {
if ($vs_f != 'item_id') {
continue;
}
// Include sub-items
$t_list_item = new ca_list_items();
$va_item_ids = $t_list_item->getHierarchy((int) $vs_v, array('idsOnly' => true, 'includeSelf' => true));
$va_item_ids[] = (int) $vs_v;
$va_attr_sql[] = "(ca_attribute_values.{$vs_f} IN (?))";
$va_attr_values[] = $va_item_ids;
} else {
$va_attr_sql[] = "(ca_attribute_values.{$vs_f} " . (is_null($vs_v) ? " IS " : " = ") . " ?)";
$va_attr_values[] = $vs_v;
}
}
}
if ($vs_attr_sql = join(" AND ", $va_attr_sql)) {
$vs_attr_sql = " AND " . $vs_attr_sql;
}
if ($vn_i == 0) {
$vs_sql = "\n\t\t\t\t\t\t\t\t\t\t\t\tSELECT " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->ops_browse_table_name . "\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_relative_to_join}\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes ON ca_attributes.row_id = {$vs_target_browse_table_name}.{$vs_target_browse_table_pk} AND ca_attributes.table_num = ?\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values ON ca_attribute_values.attribute_id = ca_attributes.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t(ca_attribute_values.element_id = ?) {$vs_attr_sql}";
$qr_res = $this->opo_db->query($vs_sql, $va_attr_values);
} else {
$vs_sql = "\n\t\t\t\t\t\t\t\t\t\t\t\tSELECT " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->ops_browse_table_name . "\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_relative_to_join}\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes ON ca_attributes.row_id = {$vs_target_browse_table_name}.{$vs_target_browse_table_pk} AND ca_attributes.table_num = ?\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values ON ca_attribute_values.attribute_id = ca_attributes.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t(ca_attribute_values.element_id = ?) {$vs_attr_sql}";
$qr_res = $this->opo_db->query($vs_sql, $va_attr_values);
}
$va_acc[$vn_i] = $qr_res->getAllFieldValues($this->ops_browse_table_name . '.' . $t_item->primaryKey());
$vn_i++;
示例4: getDisplayValue
/**
* Options:
* rawDate - if true, returns date as an array of start and end historic timestames
* sortable - if true a language-independent sortable representation is returned.
* getDirectDate - get underlying historic timestamp (floatval)
*/
public function getDisplayValue($pa_options = null)
{
if (!is_array($pa_options)) {
$pa_options = array();
}
if (isset($pa_options['rawDate']) && $pa_options['rawDate']) {
return array(0 => $this->opn_start_date, 1 => $this->opn_end_date, 'start' => $this->opn_start_date, 'end' => $this->opn_end_date);
}
if (isset($pa_options['GET_DIRECT_DATE']) && $pa_options['GET_DIRECT_DATE'] || isset($pa_options['getDirectDate']) && $pa_options['getDirectDate']) {
return $this->opn_start_date;
}
if (isset($pa_options['sortable']) && $pa_options['sortable']) {
if (!$this->opn_start_date || !$this->opn_end_date) {
return null;
}
return $this->opn_start_date . '/' . $this->opn_end_date;
}
$o_config = Configuration::load();
$o_date_config = Configuration::load($o_config->get('datetime_config'));
if ($o_date_config->get('dateFormat') == 'original') {
return $this->ops_text_value;
} else {
$t_element = new ca_metadata_elements($this->getElementID());
$va_settings = $this->getSettingValuesFromElementArray($t_element->getFieldValuesArray(), array('isLifespan'));
$o_tep = new TimeExpressionParser();
$o_tep->setHistoricTimestamps($this->opn_start_date, $this->opn_end_date);
return $o_tep->getText(array_merge(array('isLifespan' => $va_settings['isLifespan']), $pa_options));
//$this->ops_text_value;
}
}
示例5: search
//.........这里部分代码省略.........
//
// For certain types of attributes we can directly query the
// attributes in the database rather than using the full text index
// This allows us to do "intelligent" querying... for example on date ranges
// parsed from natural language input and for length dimensions using unit conversion
//
switch ($t_element->get('datatype')) {
case 2:
// dates
$vb_exact = $vs_term[0] == "#" ? true : false;
// dates prepended by "#" are considered "exact" or "contained - the matched dates must be wholly contained by the search term
if ($vb_exact) {
if ($this->opo_tep->parse($vs_term)) {
// TODO: fix date handling to reflect distinctions in ranges
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_access_point));
}
} else {
if ($this->opo_tep->parse($vs_term)) {
// TODO: fix date handling to reflect distinctions in ranges
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_access_point));
}
}
break;
case 4:
// geocode
$t_geocode = new GeocodeAttributeValue();
if ($va_coords = caParseGISSearch($vs_term)) {
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $va_coords['min_latitude'] . ',' . $va_coords['min_longitude'] . " TO " . $va_coords['max_latitude'] . ',' . $va_coords['max_longitude'] . ']', $vs_access_point));
}
break;
case 6:
// currency
$t_cur = new CurrencyAttributeValue();
$va_parsed_value = $t_cur->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_amount = (double) $va_parsed_value['value_decimal1'];
$vs_currency = preg_replace('![^A-Z0-9]+!', '', $va_parsed_value['value_longtext1']);
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_amount, $vs_access_point));
break;
case 8:
// length
$t_len = new LengthAttributeValue();
$va_parsed_value = $t_len->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_len = (double) $va_parsed_value['value_decimal1'];
// this is always in meters so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_len, $vs_access_point));
break;
case 9:
// weight
$t_weight = new WeightAttributeValue();
$va_parsed_value = $t_weight->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_weight = (double) $va_parsed_value['value_decimal1'];
// this is always in kilograms so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_weight, $vs_access_point));
break;
case 10:
// timecode
$t_timecode = new TimecodeAttributeValue();
$va_parsed_value = $t_timecode->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_timecode = (double) $va_parsed_value['value_decimal1'];
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_timecode, $vs_access_point));
break;
case 11:
// integer
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term((double) $vs_term, $vs_access_point));
break;
case 12:
示例6: _doQueriesForSqlSearch
//.........这里部分代码省略.........
break;
}
}
$vs_raw_term = join(' ', $va_raw_terms);
$vb_exact = $vs_raw_term[0] == "#" ? true : false;
// dates prepended by "#" are considered "exact" or "contained - the matched dates must be wholly contained by the search term
if ($vb_exact) {
$vs_raw_term = substr($vs_raw_term, 1);
if ($this->opo_tep->parse($vs_raw_term)) {
$va_dates = $this->opo_tep->getHistoricTimestamps();
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 BETWEEN " . floatval($va_dates['start']) . " AND " . floatval($va_dates['end']) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal2 BETWEEN " . floatval($va_dates['start']) . " AND " . floatval($va_dates['end']) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
}
} else {
if ($this->opo_tep->parse($vs_raw_term)) {
$va_dates = $this->opo_tep->getHistoricTimestamps();
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 BETWEEN " . floatval($va_dates['start']) . " AND " . floatval($va_dates['end']) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal2 BETWEEN " . floatval($va_dates['start']) . " AND " . floatval($va_dates['end']) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 <= " . floatval($va_dates['start']) . " AND cav.value_decimal2 >= " . floatval($va_dates['end']) . ")\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
}
}
break;
case __CA_ATTRIBUTE_VALUE_GEOCODE__:
// At this point $va_raw_terms has been tokenized by Lucene into oblivion
// and is also dependent on the search_tokenizer_regex so we can't really do anything with it.
// We now build our own un-tokenized term array instead. caParseGISSearch() can handle it.
$va_gis_terms = array();
foreach ($o_lucene_query_element->getQueryTerms() as $o_term) {
$va_gis_terms[] = trim((string) $o_term->text);
}
if ($va_coords = caParseGISSearch(join(' ', $va_gis_terms))) {
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 BETWEEN {$va_coords['min_latitude']} AND {$va_coords['max_latitude']})\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal2 BETWEEN {$va_coords['min_longitude']} AND {$va_coords['max_longitude']})\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
}
break;
case __CA_ATTRIBUTE_VALUE_CURRENCY__:
$t_cur = new CurrencyAttributeValue();
$va_parsed_value = $t_cur->parseValue(join(' ', $va_raw_terms), $t_element->getFieldValuesArray());
$vn_amount = $va_parsed_value['value_decimal1'];
$vs_currency = preg_replace('![^A-Z0-9]+!', '', $va_parsed_value['value_longtext1']);
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 = " . floatval($vn_amount) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_longtext1 = '" . $this->opo_db->escape($vs_currency) . "')\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
break;
case __CA_ATTRIBUTE_VALUE_LENGTH__:
// If it looks like a dimension that has been tokenized by Lucene
// into oblivion rehydrate it here.
try {
switch (sizeof($va_raw_terms)) {
case 2:
$vs_dimension = $va_raw_terms[0] . caGetDecimalSeparator() . $va_raw_terms[1];
break;
case 3:
$vs_dimension = $va_raw_terms[0] . caGetDecimalSeparator() . $va_raw_terms[1] . " " . $va_raw_terms[2];
break;
default:
$vs_dimension = join(' ', $va_raw_terms);
}
$vo_parsed_measurement = caParseLengthDimension($vs_dimension);
$vn_len = $vo_parsed_measurement->convertTo('METER', 6, 'en_US');
} catch (Exception $e) {
$vs_direct_sql_query = null;
break;
}
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT ca.row_id, 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM ca_attribute_values cav\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes AS ca ON ca.attribute_id = cav.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t^JOIN\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.element_id = {$vn_fld_num}) AND (ca.table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(cav.value_decimal1 = " . floatval($vn_len) . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
break;
case __CA_ATTRIBUTE_VALUE_WEIGHT__:
// If it looks like a weight that has been tokenized by Lucene
// into oblivion rehydrate it here.
try {
switch (sizeof($va_raw_terms)) {
case 2:
示例7: search
//.........这里部分代码省略.........
if ($t_element->load(array('element_code' => $vs_sub_field ? $vs_sub_field : $vs_field))) {
$vs_fld_num = $t_element->getPrimaryKey();
//
// For certain types of attributes we can directly query the
// attributes in the database rather than using the full text index
// This allows us to do "intelligent" querying... for example on date ranges
// parsed from natural language input and for length dimensions using unit conversion
//
switch ($t_element->get('datatype')) {
case 2:
// dates
$vb_exact = $vs_term[0] == "#" ? true : false;
// dates prepended by "#" are considered "exact" or "contained - the matched dates must be wholly contained by the search term
if ($vb_exact) {
$vs_raw_term = substr($vs_term, 1);
if ($this->opo_tep->parse($vs_term)) {
$va_dates = $this->opo_tep->getHistoricTimestamps();
// TODO: fix date handling to reflect distinctions in ranges
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_access_point));
}
} else {
if ($this->opo_tep->parse($vs_term)) {
$va_dates = $this->opo_tep->getHistoricTimestamps();
// TODO: fix date handling to reflect distinctions in ranges
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $this->opo_tep->getText(array('start_as_iso8601' => true)) . " TO " . $this->opo_tep->getText(array('end_as_iso8601' => true)) . ']', $vs_access_point));
}
}
break;
case 4:
// geocode
$t_geocode = new GeocodeAttributeValue();
if ($va_coords = caParseGISSearch($vs_term)) {
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term('[' . $va_coords['min_latitude'] . ',' . $va_coords['min_longitude'] . " TO " . $va_coords['max_latitude'] . ',' . $va_coords['max_longitude'] . ']', $vs_access_point));
}
break;
case 6:
// currency
$t_cur = new CurrencyAttributeValue();
$va_parsed_value = $t_cur->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_amount = (double) $va_parsed_value['value_decimal1'];
$vs_currency = preg_replace('![^A-Z0-9]+!', '', $va_parsed_value['value_longtext1']);
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_amount, $vs_access_point));
break;
case 8:
// length
$t_len = new LengthAttributeValue();
$va_parsed_value = $t_len->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_len = (double) $va_parsed_value['value_decimal1'];
// this is always in meters so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_len, $vs_access_point));
break;
case 9:
// weight
$t_weight = new WeightAttributeValue();
$va_parsed_value = $t_weight->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_weight = (double) $va_parsed_value['value_decimal1'];
// this is always in kilograms so we can compare this value to the one in the database
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_weight, $vs_access_point));
break;
case 10:
// timecode
$t_timecode = new TimecodeAttributeValue();
$va_parsed_value = $t_timecode->parseValue($vs_term, $t_element->getFieldValuesArray());
$vn_timecode = (double) $va_parsed_value['value_decimal1'];
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($vn_timecode, $vs_access_point));
break;
case 11:
// integer
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term((double) $vs_term, $vs_access_point));
break;
case 12:
// decimal
$o_lucene_query_element = new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term((double) $vs_term, $vs_access_point));
break;
}
}
}
}
}
}
}
}
break;
}
$va_terms[] = $o_lucene_query_element;
$va_signs[] = is_array($va_old_signs) ? array_key_exists($vn_i, $va_old_signs) ? $va_old_signs[$vn_i] : true : true;
$vn_i++;
}
$o_rewritten_query = new Zend_Search_Lucene_Search_Query_Boolean($va_terms, $va_signs);
$ps_search_expression = $this->_queryToString($o_rewritten_query);
if ($vs_filter_query = $this->_filterValueToQueryValue($pa_filters)) {
$ps_search_expression .= ' AND (' . $vs_filter_query . ')';
}
$vo_http_client = new Zend_Http_Client();
$vo_http_client->setUri($this->opo_search_config->get('search_elasticsearch_base_url') . "/" . $this->opo_search_config->get('search_elasticsearch_index_name') . "/" . $this->opo_datamodel->getTableName($pn_subject_tablenum) . "/" . "_search");
$vo_http_client->setParameterGet(array('size' => intval($this->opa_options["limit"]), 'q' => $ps_search_expression));
$vo_http_response = $vo_http_client->request();
$va_result = json_decode($vo_http_response->getBody(), true);
return new WLPlugSearchEngineElasticSearchResult($va_result["hits"]["hits"], $pn_subject_tablenum);
}
示例8: execute
//.........这里部分代码省略.........
$vs_sql = "\n\t\t\t\t\t\t\t\t\t\t\t\tINSERT IGNORE INTO ca_browses_tmp\n\t\t\t\t\t\t\t\t\t\t\t\tSELECT " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->ops_browse_table_name . "\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_relative_to_join}\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_browses_acc ON ca_browses_acc.row_id = " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t({$vs_table_name}.{$vs_field_name} = ?)";
//print "$vs_sql [".intval($this->opn_browse_table_num)."/".$vn_element_id."/".$vn_row_id."]<hr>";
$qr_res = $this->opo_db->query($vs_sql, (string) $vn_row_id);
$qr_res = $this->opo_db->query("TRUNCATE TABLE ca_browses_acc");
$qr_res = $this->opo_db->query("INSERT IGNORE INTO ca_browses_acc SELECT row_id FROM ca_browses_tmp");
}
$vn_i++;
}
break;
# -----------------------------------------------------
# -----------------------------------------------------
case 'attribute':
$t_element = new ca_metadata_elements();
if (!$t_element->load(array('element_code' => $va_facet_info['element_code']))) {
return array();
}
$vn_datatype = $t_element->get('datatype');
if ($va_facet_info['relative_to']) {
if ($va_relative_execute_sql_data = $this->_getRelativeExecuteSQLData($va_facet_info['relative_to'], $pa_options)) {
$va_relative_to_join = $va_relative_execute_sql_data['relative_joins'];
$vs_relative_to_join = join("\n", $va_relative_to_join);
$vs_target_browse_table_name = $va_relative_execute_sql_data['target_table_name'];
$vs_target_browse_table_num = $va_relative_execute_sql_data['target_table_num'];
$vs_target_browse_table_pk = $va_relative_execute_sql_data['target_table_pk'];
}
}
// TODO: check that it is a *single-value* (ie. no hierarchical ca_metadata_elements) Text or Number attribute
// (do we support other types as well?)
$vn_element_id = $t_element->getPrimaryKey();
$o_attr = Attribute::getValueInstance($t_element->get('datatype'));
foreach ($va_row_ids as $vn_row_id) {
$vn_row_id = urldecode($vn_row_id);
$vn_row_id = str_replace('/', '/', $vn_row_id);
$va_value = $o_attr->parseValue($vn_row_id, $t_element->getFieldValuesArray());
$va_attr_sql = array();
$va_attr_values = array(intval($vs_target_browse_table_num), $vn_element_id);
if (is_array($va_value)) {
foreach ($va_value as $vs_f => $vs_v) {
if ($vn_datatype == 3) {
// list
$t_list_item = new ca_list_items((int) $vs_v);
// Include sub-items
$va_item_ids = $t_list_item->getHierarchy((int) $vs_v, array('idsOnly' => true, 'includeSelf' => true));
$va_item_ids[] = (int) $vs_v;
$va_attr_sql[] = "(ca_attribute_values.{$vs_f} IN (?))";
$va_attr_values[] = $va_item_ids;
} else {
$va_attr_sql[] = "(ca_attribute_values.{$vs_f} " . (is_null($vs_v) ? " IS " : " = ") . " ?)";
$va_attr_values[] = $vs_v;
}
}
}
if ($vs_attr_sql = join(" AND ", $va_attr_sql)) {
$vs_attr_sql = " AND " . $vs_attr_sql;
}
if ($vn_i == 0) {
$vs_sql = "\n\t\t\t\t\t\t\t\t\t\t\t\tINSERT IGNORE INTO ca_browses_acc\n\t\t\t\t\t\t\t\t\t\t\t\tSELECT " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->ops_browse_table_name . "\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_relative_to_join}\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes ON ca_attributes.row_id = {$vs_target_browse_table_name}.{$vs_target_browse_table_pk} AND ca_attributes.table_num = ?\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values ON ca_attribute_values.attribute_id = ca_attributes.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t(ca_attribute_values.element_id = ?) {$vs_attr_sql}";
//caDebug($vs_sql);
//caDebug(intval($vs_target_browse_table_num)."/".$vn_element_id."/".$vn_row_id);
//caDebug($va_attr_values);
$qr_res = $this->opo_db->query($vs_sql, $va_attr_values);
} else {
$qr_res = $this->opo_db->query("TRUNCATE TABLE ca_browses_tmp");
$vs_sql = "\n\t\t\t\t\t\t\t\t\t\t\t\tINSERT IGNORE INTO ca_browses_tmp\n\t\t\t\t\t\t\t\t\t\t\t\tSELECT " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->ops_browse_table_name . "\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_relative_to_join}\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes ON ca_attributes.row_id = {$vs_target_browse_table_name}.{$vs_target_browse_table_pk} AND ca_attributes.table_num = ?\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values ON ca_attribute_values.attribute_id = ca_attributes.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_browses_acc ON ca_browses_acc.row_id = " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t(ca_attribute_values.element_id = ?) {$vs_attr_sql}";
//print "$vs_sql [".intval($vs_target_browse_table_num)."/".$vn_element_id."/".$vn_row_id."]<hr>";print_R($va_attr_values);
$qr_res = $this->opo_db->query($vs_sql, $va_attr_values);