当前位置: 首页>>代码示例>>PHP>>正文


PHP BaseModel::primaryKey方法代码示例

本文整理汇总了PHP中BaseModel::primaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::primaryKey方法的具体用法?PHP BaseModel::primaryKey怎么用?PHP BaseModel::primaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseModel的用法示例。


在下文中一共展示了BaseModel::primaryKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: caProcessRelationshipLookupLabel

/**
 * Converts result set into display labels for relationship lookup
 *
 * @param SearchResult $qr_rel_items 
 * @param BaseModel $pt_rel
 * @param array $pa_options Array of options, including:
 *		stripTags = default is false
 * 		exclude = list of primary key values to omit from returned list
 *		config = 
 *		limit = maximum number of items to return; if omitted all items are returned
 *		inlineCreateMessage = 
 *		inlineCreateQuery =
 *		inlineCreateMessageDoesNotExist =
 *		template = 
 *		primaryIDs = row_ids for primary rows in related table, keyed by table name; when resolving ambiguous relationships the row_ids will be excluded from consideration. This option is rarely used and exists primarily to take care of a single
 *						edge case: you are processing a template relative to a self-relationship such as ca_entities_x_entities that includes references to the subject table (ca_entities, in the case of ca_entities_x_entities). There are
 *						two possible paths to take in this situations; primaryIDs lets you specify which ones you *don't* want to take by row_id. For interstitial editors, the ids will be set to a single id: that of the subject (Eg. ca_entities) row
 *						from which the interstitial was launched.
 * @return mixed 
 */
function caProcessRelationshipLookupLabel($qr_rel_items, $pt_rel, $pa_options = null)
{
    $va_initial_values = array();
    $vs_hier_fld = $pt_rel->getProperty('HIERARCHY_ID_FLD');
    $vs_idno_fld = $pt_rel->getProperty('ID_NUMBERING_ID_FIELD');
    $vs_idno_sort_fld = $pt_rel->getProperty('ID_NUMBERING_SORT_FIELD');
    $vs_rel_pk = caGetOption('primaryKey', $pa_options, $pt_rel->primaryKey());
    $vs_rel_table = caGetOption('table', $pa_options, $pt_rel->tableName());
    $o_config = !isset($pa_options['config']) || !is_object($pa_options['config']) ? Configuration::load() : $pa_options['config'];
    $pn_limit = caGetOption('limit', $pa_options, null);
    $ps_inline_create_message = caGetOption('inlineCreateMessage', $pa_options, null);
    $ps_inline_create_does_not_exist_message = caGetOption('inlineCreateMessageDoesNotExist', $pa_options, null);
    $ps_inline_create_query = caGetOption('inlineCreateQuery', $pa_options, null);
    $ps_inline_create_query_lc = mb_strtolower($ps_inline_create_query);
    $ps_empty_result_message = caGetOption('emptyResultMessage', $pa_options, null);
    $ps_empty_result_query = caGetOption('emptyResultQuery', $pa_options, null);
    $vs_template = caGetOption('template', $pa_options, null);
    $va_exclude = caGetOption('exclude', $pa_options, array(), array('castTo' => 'array'));
    $va_display_format = $o_config->getList("{$vs_rel_table}_lookup_settings");
    $vs_display_delimiter = $o_config->get("{$vs_rel_table}_lookup_delimiter");
    if (!$vs_template) {
        $vs_template = join($vs_display_delimiter, $va_display_format);
    }
    $va_related_item_info = $va_parent_ids = $va_hierarchy_ids = array();
    $va_items = array();
    $o_dm = Datamodel::load();
    $t_rel = $o_dm->getInstanceByTableName($vs_rel_table, true);
    $vs_type_id_fld = method_exists($t_rel, 'getTypeFieldName') ? $t_rel->getTypeFieldName() : null;
    $vn_c = 0;
    $vb_include_inline_add_does_not_exist_message = $vb_include_empty_result_message = false;
    $vb_include_inline_add_message = true;
    if (is_object($qr_rel_items)) {
        if (!$qr_rel_items->numHits()) {
            if ($ps_inline_create_does_not_exist_message) {
                $vb_include_inline_add_does_not_exist_message = true;
                $vb_include_inline_add_message = false;
            } else {
                if ($ps_empty_result_message) {
                    $vb_include_empty_result_message = true;
                }
            }
        } else {
            $vs_table = $qr_rel_items->tableName();
            $vs_pk = $qr_rel_items->primaryKey();
            $va_primary_ids = method_exists($pt_rel, "isSelfRelationship") && ($vb_is_self_rel = $pt_rel->isSelfRelationship()) ? caGetOption("primaryIDs", $pa_options, null) : null;
            while ($qr_rel_items->nextHit()) {
                $vn_id = $qr_rel_items->get("{$vs_rel_table}.{$vs_rel_pk}");
                if (in_array($vn_id, $va_exclude)) {
                    continue;
                }
                $va_item = array('id' => $vn_id, $vs_rel_pk => $vn_id);
                if ($vs_type_id_fld) {
                    $va_item['type_id'] = $qr_rel_items->get("{$vs_rel_table}.{$vs_type_id_fld}");
                }
                $va_item['_display'] = caProcessTemplateForIDs($vs_template, $vs_table, array($qr_rel_items->get("{$vs_table}.{$vs_pk}")), array('returnAsArray' => false, 'returnAsLink' => false, 'delimiter' => caGetOption('delimiter', $pa_options, $vs_display_delimiter), 'resolveLinksUsing' => $vs_rel_table, 'primaryIDs' => $va_primary_ids));
                $va_item['label'] = mb_strtolower($qr_rel_items->get("{$vs_table}.preferred_labels"));
                $va_items[$vn_id] = $va_item;
                $vn_c++;
                if ($pn_limit && $pn_limit <= $vn_c) {
                    break;
                }
            }
        }
    }
    if (isset($pa_options['relatedItems']) && is_array($pa_options['relatedItems']) && sizeof($pa_options['relatedItems'])) {
        $va_tmp = array();
        foreach ($pa_options['relatedItems'] as $vn_relation_id => $va_relation) {
            $va_items[$va_relation[$vs_rel_pk]]['relation_id'] = $va_relation['relation_id'];
            $va_items[$va_relation[$vs_rel_pk]]['relationship_type_id'] = $va_items[$va_relation[$vs_rel_pk]]['type_id'] = $va_relation['direction'] ? $va_relation['direction'] . '_' . $va_relation['relationship_type_id'] : $va_relation['relationship_type_id'];
            $va_items[$va_relation[$vs_rel_pk]]['rel_type_id'] = $va_relation['relationship_type_id'];
            $va_items[$va_relation[$vs_rel_pk]]['relationship_typename'] = $va_relation['relationship_typename'];
            $va_items[$va_relation[$vs_rel_pk]]['idno'] = $va_relation[$vs_idno_fld];
            $va_items[$va_relation[$vs_rel_pk]]['idno_sort'] = $va_relation[$vs_idno_sort_fld];
            $va_items[$va_relation[$vs_rel_pk]]['label'] = $va_relation['label'];
            $va_items[$va_relation[$vs_rel_pk]]['direction'] = $va_relation['direction'];
            $va_items[$va_relation[$vs_rel_pk]]['effective_date'] = $va_relation['effective_date'];
            if (isset($va_relation['surname'])) {
                // pass forename and surname entity label fields to support proper sorting by name
                $va_items[$va_relation[$vs_rel_pk]]['surname'] = $va_relation['surname'];
                $va_items[$va_relation[$vs_rel_pk]]['forename'] = $va_relation['forename'];
//.........这里部分代码省略.........
开发者ID:kai-iak,项目名称:providence,代码行数:101,代码来源:displayHelpers.php

示例2: _indexAttribute


//.........这里部分代码省略.........
                             }
                         }
                         $va_tmp[$vo_attribute->getAttributeID()] = $vs_value_to_index;
                     }
                 }
             } else {
                 // Delete indexing
                 $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $vn_element_id, $pn_row_id, '', $pa_data);
             }
             if (is_array($va_tmp) && sizeof($va_tmp)) {
                 $va_new_values = array();
                 if ($t_item = AuthorityAttributeValue::elementTypeToInstance($vn_datatype)) {
                     $va_labels = $t_item->getPreferredDisplayLabelsForIDs($va_tmp, array('returnAllLocales' => true));
                     foreach ($va_labels as $vn_row_id => $va_labels_per_row) {
                         foreach ($va_labels_per_row as $vn_locale_id => $va_label_list) {
                             foreach ($va_label_list as $vs_label) {
                                 $va_new_values[$vn_row_id][$vs_label] = true;
                             }
                         }
                     }
                     foreach ($va_tmp as $vn_attribute_id => $vn_item_id) {
                         if (!$vn_item_id) {
                             continue;
                         }
                         if (!isset($va_new_values[$vn_item_id]) || !is_array($va_new_values[$vn_item_id])) {
                             continue;
                         }
                         $vs_v = join(' ;  ', array_merge(array($vn_item_id), array_keys($va_new_values[$vn_item_id])));
                         $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $vn_element_id, $pn_row_id, $vs_v, $pa_data);
                         if ($va_hier_values = $this->_genHierarchicalPath($vn_item_id, "preferred_labels." . $t_item->getLabelDisplayField(), $t_item, $pa_data)) {
                             $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $vn_element_id, $pn_row_id, $vs_v . ' ' . join(" ", $va_hier_values['values']), $pa_data);
                             if (caGetOption('INDEX_ANCESTORS_AS_PATH_WITH_DELIMITER', $pa_data, false) !== false) {
                                 $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $vn_element_id, $pn_row_id, $va_hier_values['path'], array_merge($pa_data, array('DONT_TOKENIZE' => 1)));
                             }
                         }
                     }
                 }
             }
             break;
         default:
             $vn_element_id = is_numeric($pm_element_code_or_id) ? $pm_element_code_or_id : $this->_getElementID($pm_element_code_or_id);
             $va_attributes = $pt_subject->getAttributesByElement($pm_element_code_or_id, array('row_id' => $pn_row_id));
             if (!is_array($va_attributes)) {
                 $va_attributes = array();
             }
             if (sizeof($va_attributes) > 0) {
                 foreach ($va_attributes as $vo_attribute) {
                     foreach ($vo_attribute->getValues() as $vo_value) {
                         $vs_value_to_index = $vo_value->getDisplayValue();
                         $va_additional_indexing = $vo_value->getDataForSearchIndexing();
                         if (is_array($va_additional_indexing) && sizeof($va_additional_indexing) > 0) {
                             foreach ($va_additional_indexing as $vs_additional_value) {
                                 $vs_value_to_index .= " ; " . $vs_additional_value;
                             }
                         }
                         $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $vn_element_id, $pn_row_id, $vs_value_to_index, $pa_data);
                     }
                 }
             } else {
                 // Delete indexing
                 $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $vn_element_id, $pn_row_id, '', $pa_data);
             }
             $vs_subject_pk = $pt_subject->primaryKey();
             // reindex children?
             if (caGetOption('INDEX_ANCESTORS', $pa_data, false) !== false || in_array('INDEX_ANCESTORS', $pa_data)) {
                 if ($pt_subject && $pt_subject->isHierarchical()) {
                     if ($va_hier_values = $this->_genHierarchicalPath($pn_row_id, $vs_element_code = $this->_getElementCode($vn_element_id), $pt_subject, $pa_data)) {
                         $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $vn_element_id, $pn_row_id, join(" ", $va_hier_values['values']), $pa_data);
                         if (caGetOption('INDEX_ANCESTORS_AS_PATH_WITH_DELIMITER', $pa_data, false) !== false) {
                             $this->opo_engine->indexField($pn_subject_tablenum, 'A' . $vn_element_id, $pn_row_id, $va_hier_values['path'], array_merge($pa_data, array('DONT_TOKENIZE' => 1)));
                         }
                     }
                     $va_children_ids = $pt_subject->getHierarchyAsList($pn_row_id, array('idsOnly' => true, 'includeSelf' => false));
                     if (!$pb_reindex_mode && is_array($va_children_ids) && sizeof($va_children_ids) > 0) {
                         // trigger reindexing of children
                         $o_indexer = new SearchIndexer($this->opo_db);
                         $pt_subject->load($pn_row_id);
                         $va_content = $pt_subject->get($pt_subject->tableName() . "." . $vs_element_code, array('returnAsArray' => true, 'returnAllLocales' => true));
                         foreach ($va_children_ids as $vn_id) {
                             if ($vn_id == $pn_row_id) {
                                 continue;
                             }
                             $o_indexer->opo_engine->startRowIndexing($pn_subject_tablenum, $vn_id);
                             foreach ($va_content as $vn_i => $va_by_locale) {
                                 foreach ($va_by_locale as $vn_locale_id => $va_content_list) {
                                     foreach ($va_content_list as $va_content_container) {
                                         $o_indexer->opo_engine->indexField($pn_subject_tablenum, 'A' . $vn_element_id, $vn_id, $va_content_container[$vs_element_code], array_merge($pa_data, array('DONT_TOKENIZE' => 1)));
                                     }
                                 }
                             }
                             $o_indexer->opo_engine->commitRowIndexing();
                         }
                     }
                     continue;
                 }
             }
             break;
     }
     return true;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:101,代码来源:SearchIndexer.php

示例3: _getAttributeValue

 /**
  * get() value for attribute
  *
  * @param array $pa_value_list
  * @param BaseModel $pt_instance
  * @param array Options
  *
  * @return array|string
  */
 private function _getAttributeValue($pa_value_list, $pt_instance, $pa_options)
 {
     $va_path_components =& $pa_options['pathComponents'];
     $va_return_values = array();
     $vn_id = $this->get($pt_instance->primaryKey(true));
     $vs_table_name = $pt_instance->tableName();
     if (is_array($pa_value_list) && sizeof($pa_value_list)) {
         foreach ($pa_value_list as $o_attribute) {
             $va_values = $o_attribute->getValues();
             if ($pa_options['useLocaleCodes']) {
                 if (!$o_attribute->getLocaleID() || !($vm_locale_id = $this->opo_locales->localeIDToCode($o_attribute->getLocaleID()))) {
                     $vm_locale_id = __CA_DEFAULT_LOCALE__;
                 }
             } else {
                 if (!($vm_locale_id = $o_attribute->getLocaleID())) {
                     $vm_locale_id = $this->opo_locales->localeCodeToID(__CA_DEFAULT_LOCALE__);
                 }
             }
             foreach ($va_values as $o_value) {
                 $vs_element_code = $o_value->getElementCode();
                 if ($va_path_components['subfield_name']) {
                     if ($va_path_components['subfield_name'] && $va_path_components['subfield_name'] !== $vs_element_code && !$o_value instanceof InformationServiceAttributeValue) {
                         continue;
                     }
                 }
                 switch ($o_value->getType()) {
                     case __CA_ATTRIBUTE_VALUE_LIST__:
                         $t_element = $pt_instance->_getElementInstance($o_value->getElementID());
                         $vn_list_id = $t_element->get('list_id');
                         $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'], 'list_id' => $vn_list_id)));
                         break;
                     case __CA_ATTRIBUTE_VALUE_INFORMATIONSERVICE__:
                         //ca_objects.informationservice.ulan_container
                         // support subfield notations like ca_objects.wikipedia.abstract, but only if we're not already at subfield-level, e.g. ca_objects.container.wikipedia
                         if ($va_path_components['subfield_name'] && $vs_element_code != $va_path_components['subfield_name'] && $vs_element_code == $va_path_components['field_name']) {
                             $vs_val_proc = $o_value->getExtraInfo($va_path_components['subfield_name']);
                             break;
                         }
                         // support ca_objects.container.wikipedia.abstract
                         if ($vs_element_code == $va_path_components['subfield_name'] && $va_path_components['num_components'] == 4) {
                             $vs_val_proc = $o_value->getExtraInfo($va_path_components['components'][3]);
                             break;
                         }
                         // support ca_objects.wikipedia or ca_objects.container.wikipedia (Eg. no "extra" value specified)
                         if ($vs_element_code == $va_path_components['field_name'] || $vs_element_code == $va_path_components['subfield_name']) {
                             $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'])));
                             break;
                         }
                         continue;
                     default:
                         $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'])));
                         break;
                 }
                 if ($pa_options['makeLink']) {
                     $vs_val_proc = array_shift(caCreateLinksFromText(array($vs_val_proc), $vs_table_name, array($vn_id)));
                 }
                 if ($pa_options['returnWithStructure']) {
                     $va_return_values[(int) $vn_id][$vm_locale_id][(int) $o_attribute->getAttributeID()][$vs_element_code] = $vs_val_proc;
                 } else {
                     $va_return_values[(int) $vn_id][$vm_locale_id][(int) $o_attribute->getAttributeID()] = $vs_val_proc;
                 }
             }
         }
     } else {
         // is blank
         if ($pa_options['returnWithStructure'] && $pa_options['returnBlankValues']) {
             $va_return_values[(int) $vn_id][null][null][$va_path_components['subfield_name'] ? $va_path_components['subfield_name'] : $va_path_components['field_name']] = '';
         }
     }
     if (!$pa_options['returnAllLocales']) {
         $va_return_values = caExtractValuesByUserLocale($va_return_values);
     }
     if ($pa_options['returnWithStructure']) {
         return is_array($va_return_values) ? $va_return_values : array();
     }
     //
     // Flatten array for return as string or simple array value
     //
     $va_flattened_values = $this->_flattenArray($va_return_values, $pa_options);
     if ($pa_options['returnAsArray']) {
         return $va_flattened_values;
     } else {
         return sizeof($va_flattened_values) > 0 ? join($pa_options['delimiter'], $va_flattened_values) : null;
     }
 }
开发者ID:kai-iak,项目名称:providence,代码行数:94,代码来源:SearchResult.php

示例4: _getAttributeValue

 /**
  * get() value for attribute
  *
  * @param array $pa_value_list
  * @param BaseModel $pt_instance
  * @param array Options
  *
  * @return array|string
  */
 private function _getAttributeValue($pa_value_list, $pt_instance, $pa_options)
 {
     $va_path_components =& $pa_options['pathComponents'];
     $vs_delimiter = isset($pa_options['delimiter']) ? $pa_options['delimiter'] : ';';
     $va_return_values = array();
     $vn_id = $this->get($pt_instance->primaryKey(true));
     $vs_table_name = $pt_instance->tableName();
     if (is_array($pa_value_list) && sizeof($pa_value_list)) {
         $va_val_proc = array();
         foreach ($pa_value_list as $o_attribute) {
             $t_attr_element = $pt_instance->_getElementInstance($o_attribute->getElementID());
             $vn_attr_type = $t_attr_element->get('datatype');
             $va_acc = array();
             $va_values = $o_attribute->getValues();
             if ($pa_options['useLocaleCodes']) {
                 if (!$o_attribute->getLocaleID() || !($vm_locale_id = SearchResult::$opo_locales->localeIDToCode($o_attribute->getLocaleID()))) {
                     $vm_locale_id = __CA_DEFAULT_LOCALE__;
                 }
             } else {
                 if (!($vm_locale_id = $o_attribute->getLocaleID())) {
                     $vm_locale_id = SearchResult::$opo_locales->localeCodeToID(__CA_DEFAULT_LOCALE__);
                 }
             }
             $vb_did_return_value = false;
             foreach ($va_values as $o_value) {
                 $vs_val_proc = null;
                 $vb_dont_return_value = false;
                 $vs_element_code = $o_value->getElementCode();
                 $va_auth_spec = null;
                 if (is_a($o_value, "AuthorityAttributeValue")) {
                     $va_auth_spec = $va_path_components['components'];
                     if ($pt_instance->hasElement($va_path_components['subfield_name'], null, true, array('dontCache' => false))) {
                         array_shift($va_auth_spec);
                         array_shift($va_auth_spec);
                         array_shift($va_auth_spec);
                     } elseif ($pt_instance->hasElement($va_path_components['field_name'], null, true, array('dontCache' => false))) {
                         array_shift($va_auth_spec);
                         array_shift($va_auth_spec);
                         $va_path_components['subfield_name'] = null;
                     }
                 }
                 if ($va_path_components['subfield_name'] && $va_path_components['subfield_name'] !== $vs_element_code && !$o_value instanceof InformationServiceAttributeValue) {
                     $vb_dont_return_value = true;
                     if (!$pa_options['filter']) {
                         continue;
                     }
                 }
                 if (is_a($o_value, "AuthorityAttributeValue") && sizeof($va_auth_spec) > 0) {
                     array_unshift($va_auth_spec, $vs_auth_table_name = $o_value->tableName());
                     if ($qr_res = caMakeSearchResult($vs_auth_table_name, array($o_value->getID()))) {
                         if ($qr_res->nextHit()) {
                             unset($pa_options['returnWithStructure']);
                             $va_options['returnAsArray'] = true;
                             $va_val_proc = $qr_res->get(join(".", $va_auth_spec), $pa_options);
                             if (is_array($va_val_proc)) {
                                 foreach ($va_val_proc as $vn_i => $vs_v) {
                                     $va_return_values[(int) $vn_id][$vm_locale_id][(int) $o_attribute->getAttributeID() . "_{$vn_i}"][$vs_element_code] = $vs_v;
                                 }
                             }
                         }
                     }
                     continue;
                 }
                 if (is_null($vs_val_proc)) {
                     switch ($o_value->getType()) {
                         case __CA_ATTRIBUTE_VALUE_LIST__:
                             $t_element = $pt_instance->_getElementInstance($o_value->getElementID());
                             $vn_list_id = $t_element->get('list_id');
                             $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'], 'list_id' => $vn_list_id)));
                             break;
                         case __CA_ATTRIBUTE_VALUE_INFORMATIONSERVICE__:
                             //ca_objects.informationservice.ulan_container
                             // support subfield notations like ca_objects.wikipedia.abstract, but only if we're not already at subfield-level, e.g. ca_objects.container.wikipedia
                             if ($va_path_components['subfield_name'] && $vs_element_code != $va_path_components['subfield_name'] && $vs_element_code == $va_path_components['field_name']) {
                                 $vs_val_proc = $o_value->getExtraInfo($va_path_components['subfield_name']);
                                 $vb_dont_return_value = false;
                                 break;
                             }
                             // support ca_objects.container.wikipedia.abstract
                             if ($vs_element_code == $va_path_components['subfield_name'] && $va_path_components['num_components'] == 4) {
                                 $vs_val_proc = $o_value->getExtraInfo($va_path_components['components'][3]);
                                 $vb_dont_return_value = false;
                                 break;
                             }
                             // support ca_objects.wikipedia or ca_objects.container.wikipedia (Eg. no "extra" value specified)
                             if ($vs_element_code == $va_path_components['field_name'] || $vs_element_code == $va_path_components['subfield_name']) {
                                 $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'])));
                                 $vb_dont_return_value = false;
                                 break;
                             }
                             continue 2;
//.........这里部分代码省略.........
开发者ID:samrahman,项目名称:providence,代码行数:101,代码来源:SearchResult.php


注:本文中的BaseModel::primaryKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。