本文整理汇总了PHP中ca_occurrences::update方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_occurrences::update方法的具体用法?PHP ca_occurrences::update怎么用?PHP ca_occurrences::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_occurrences
的用法示例。
在下文中一共展示了ca_occurrences::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOccurrenceID
//.........这里部分代码省略.........
$vn_id = ca_occurrences::find($va_find_arr, array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
}
}
if (!$vn_id) {
if (isset($pa_options['dontCreate']) && $pa_options['dontCreate']) {
return false;
}
if ($o_event) {
$o_event->beginItem($vs_event_source, 'ca_occurrences', 'I');
}
$t_occurrence->setMode(ACCESS_WRITE);
$t_occurrence->set('locale_id', $pn_locale_id);
$t_occurrence->set('type_id', $pn_type_id);
$t_occurrence->set('parent_id', $pn_parent_id);
$t_occurrence->set('source_id', isset($pa_values['source_id']) ? $pa_values['source_id'] : null);
$t_occurrence->set('access', isset($pa_values['access']) ? $pa_values['access'] : 0);
$t_occurrence->set('status', isset($pa_values['status']) ? $pa_values['status'] : 0);
$t_occurrence->set('idno', $vs_idno);
$t_occurrence->set('hier_occurrence_id', isset($pa_values['hier_occurrence_id']) ? $pa_values['hier_occurrence_id'] : null);
$t_occurrence->insert();
if ($t_occurrence->numErrors()) {
if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
print "[Error] " . _t("Could not insert occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not insert occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())));
}
return null;
}
$vb_label_errors = false;
$t_occurrence->addLabel(array('name' => $ps_occ_name), $pn_locale_id, null, true);
if ($t_occurrence->numErrors()) {
if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
print "[Error] " . _t("Could not set preferred label for occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not set preferred label for occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())));
}
$vb_label_errors = true;
}
unset($pa_values['access']);
unset($pa_values['status']);
unset($pa_values['idno']);
unset($pa_values['source_id']);
unset($pa_values['hier_occurrence_id']);
$vb_attr_errors = false;
if (is_array($pa_values)) {
foreach ($pa_values as $vs_element => $va_value) {
if (is_array($va_value)) {
// array of values (complex multi-valued attribute)
$t_occurrence->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element);
} else {
// scalar value (simple single value attribute)
if ($va_value) {
$t_occurrence->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element);
}
}
}
}
$t_occurrence->update();
if ($t_occurrence->numErrors()) {
if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
print "[Error] " . _t("Could not set values for occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not set values for occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())));
}
$vb_attr_errors = true;
}
$vn_occurrence_id = $t_occurrence->getPrimaryKey();
if ($o_event) {
if ($vb_attr_errors || $vb_label_errors) {
$o_event->endItem($vn_occurrence_id, __CA_DATA_IMPORT_ITEM_PARTIAL_SUCCESS__, _t("Errors setting field values: %1", join('; ', $t_occurrence->getErrors())));
} else {
$o_event->endItem($vn_occurrence_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
}
}
if ($o_log) {
$o_log->logInfo(_t("Created new occurrence %1", $ps_occ_name));
}
if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
return $t_occurrence;
}
} else {
if ($o_event) {
$o_event->beginItem($vs_event_source, 'ca_occurrences', 'U');
}
$vn_occurrence_id = $vn_id;
if ($o_event) {
$o_event->endItem($vn_occurrence_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
}
if ($o_log) {
$o_log->logDebug(_t("Found existing occurrence %1 in DataMigrationUtils::getOccurrenceID(); total of %2 occurrences were found", $ps_occ_name, sizeof($va_occurrence_ids) + 1));
}
if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
return new ca_occurrences($vn_occurrence_id);
}
}
return $vn_occurrence_id;
}
示例2: getOccurrenceID
//.........这里部分代码省略.........
$t_occurrence->set('hier_occurrence_id', isset($pa_values['hier_occurrence_id']) ? $pa_values['hier_occurrence_id'] : null);
$t_occurrence->insert();
if ($t_occurrence->numErrors()) {
if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
print "[Error] " . _t("Could not insert occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not insert occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())));
}
return null;
}
$vb_label_errors = false;
$t_occurrence->addLabel(array('name' => $ps_occ_name), $pn_locale_id, null, true);
if ($t_occurrence->numErrors()) {
if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
print "[Error] " . _t("Could not set preferred label for occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not set preferred label for occurrence %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())));
}
$vb_label_errors = true;
}
/** @var IIDNumbering $o_idno */
if ($o_idno = $t_occurrence->getIDNoPlugInInstance()) {
$va_values = $o_idno->htmlFormValuesAsArray('idno', $vs_idno);
if (!($vs_sep = $o_idno->getSeparator())) {
$vs_sep = '';
}
if (!is_array($va_values)) {
$va_values = array($va_values);
}
if (($vs_proc_idno = join($vs_sep, $va_values)) && $vs_proc_idno != $vs_idno) {
$t_occurrence->set('idno', $vs_proc_idno);
$t_occurrence->update();
if ($t_occurrence->numErrors()) {
if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
print "[Error] " . _t("Could not update idno for %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not idno for %1: %2", $ps_occ_name, join('; ', $t_occurrence->getErrors())));
}
return null;
}
}
}
unset($pa_values['access']);
unset($pa_values['status']);
unset($pa_values['idno']);
unset($pa_values['source_id']);
unset($pa_values['hier_occurrence_id']);
$vb_attr_errors = false;
if (is_array($pa_values)) {
foreach ($pa_values as $vs_element => $va_values) {
if (!caIsIndexedArray($va_values)) {
$va_values = array($va_values);
}
foreach ($va_values as $va_value) {
if (is_array($va_value)) {
// array of values (complex multi-valued attribute)
$t_occurrence->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element);
} else {
// scalar value (simple single value attribute)
if ($va_value) {
$t_occurrence->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element);
}
}