本文整理汇总了PHP中TimeExpressionParser::now方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeExpressionParser::now方法的具体用法?PHP TimeExpressionParser::now怎么用?PHP TimeExpressionParser::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeExpressionParser
的用法示例。
在下文中一共展示了TimeExpressionParser::now方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRelatedItems
//.........这里部分代码省略.........
if ($vn_list_id = ca_lists::getListID($vm_list)) {
$va_list_ids[] = $vn_list_id;
}
}
if (sizeof($va_list_ids)) {
$va_wheres[] = "(ca_list_items.list_id IN (" . join(",", $va_list_ids) . "))";
}
}
if ($vb_is_combo_key_relation) {
$va_joins = array("INNER JOIN {$vs_related_table_name} ON {$vs_related_table_name}.row_id = " . $this->primaryKey(true) . " AND {$vs_related_table_name}.table_num = " . $this->tableNum());
} else {
foreach ($va_path as $vs_join_table) {
$va_rel_info = $this->getAppDatamodel()->getRelationships($vs_cur_table, $vs_join_table);
$vs_join = 'INNER JOIN ' . $vs_join_table . ' ON ';
$va_tmp = array();
foreach ($va_rel_info[$vs_cur_table][$vs_join_table] as $vn_i => $va_rel) {
$va_tmp[] = $vs_cur_table . "." . $va_rel_info[$vs_cur_table][$vs_join_table][$vn_i][0] . ' = ' . $vs_join_table . '.' . $va_rel_info[$vs_cur_table][$vs_join_table][$vn_i][1] . "\n";
}
$va_joins[] = $vs_join . join(' OR ', $va_tmp);
$vs_cur_table = $vs_join_table;
}
}
// If we're getting ca_set_items, we have to rename the intrinsic row_id field because the pk is named row_id below. Hence, this hack.
if ($vs_related_table_name == 'ca_set_items') {
$va_selects[] = 'ca_set_items.row_id AS record_id';
}
$va_selects[] = $vs_subject_table_name . '.' . $this->primaryKey() . ' AS row_id';
//
// Filter to only current relationships
//
if ($pb_show_current_only && $vb_uses_effective_dates) {
// _filter_current.edatetime IS NULL criteria allows undated relationships to be considered "current"; if current filtering is done it
// is assumed that all relationships are dated and that undated relations are legacy and therefore should be considered potentially current
$vs_filter_to_current_join = "\n\t\t\t\t\tINNER JOIN (\n\t\t\t\t\t\tSELECT {$vs_item_rel_table_name}." . $this->primaryKey() . ", max({$vs_item_rel_table_name}.edatetime) edatetime\n\t\t\t\t\t\tFROM {$vs_subject_table_name}\n\t\t\t\t\t\t" . join("\n", array_merge($va_joins, $va_joins_post_add)) . "\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t(" . join(' AND ', array_merge($va_wheres, array("({$vs_item_rel_table_name}.sdatetime <= " . TimeExpressionParser::now() . ")"))) . ")\n\t\t\t\t\t\t\tOR ({$vs_item_rel_table_name}.sdatetime IS NULL)\n\t\t\t\t\t\tGROUP BY \n\t\t\t\t\t\t\t{$vs_item_rel_table_name}." . $this->primaryKey() . "\n\t\t\t\t\t) AS _filter_current ON _filter_current." . $this->primaryKey() . " = {$vs_item_rel_table_name}." . $this->primaryKey() . " AND (_filter_current.edatetime = {$vs_item_rel_table_name}.edatetime OR _filter_current.edatetime IS NULL)\n\t\t\t\t";
$va_joins[] = $vs_filter_to_current_join;
}
$vs_order_by = '';
if ($t_item_rel && $t_item_rel->hasField('rank')) {
$vs_order_by = " ORDER BY {$vs_item_rel_table_name}.rank";
$va_selects[] = $t_item_rel->tableName() . '.rank';
} else {
if ($t_rel_item && ($vs_sort = $t_rel_item->getProperty('ID_NUMBERING_SORT_FIELD'))) {
$vs_order_by = " ORDER BY {$vs_related_table}.{$vs_sort}";
$va_selects[] = "{$vs_related_table}.{$vs_sort}";
}
}
$vs_sql = "\n\t\t\t\tSELECT DISTINCT " . join(', ', $va_selects) . "\n\t\t\t\tFROM {$vs_subject_table_name}\n\t\t\t\t" . join("\n", array_merge($va_joins, $va_joins_post_add)) . "\n\t\t\t\tWHERE\n\t\t\t\t\t" . join(' AND ', $va_wheres) . "\n\t\t\t\t{$vs_order_by}\n\t\t\t";
$qr_res = $o_db->query($vs_sql);
if ($vb_uses_relationship_types) {
$va_rel_types = $t_rel->getRelationshipInfo($t_tmp->tableName());
if (method_exists($t_tmp, 'getLeftTableName')) {
$vs_left_table = $t_tmp->getLeftTableName();
$vs_direction = $vs_left_table == $vs_subject_table_name ? 'ltor' : 'rtol';
}
}
$va_rels = array();
$vn_c = 0;
if ($pn_start > 0) {
$qr_res->seek($pn_start);
}
$va_seen_row_ids = array();
while ($qr_res->nextRow()) {
if ($vn_c >= $pn_limit) {
break;
}
if (is_array($pa_primary_ids) && is_array($pa_primary_ids[$vs_related_table])) {
示例2: getLocationHistory
/**
*
*
* @param array $pa_options Array of options:
* template =
*/
public function getLocationHistory($pa_options = null)
{
$pn_object = caGetOption('object_id', $pa_options, null);
if (!($vn_object_id = $pn_object_id > 0 ? $pn_object_id : $this->getPrimaryKey())) {
return null;
}
$ps_display_template = caGetOption('template', $pa_options, '^ca_objects_x_storage_locations.relation_id');
$vn_current_date = TimeExpressionParser::now();
//
// Directly query the date field for performance
//
$o_db = $this->getDb();
$qr_res = $o_db->query("\n \t\t\tSELECT csl.relation_id, csl.location_id, csl.object_id, csl.sdatetime, csl.edatetime, csl.source_info\n \t\t\tFROM ca_objects_x_storage_locations csl\n \t\t\tINNER JOIN ca_storage_locations AS sl ON sl.location_id = csl.location_id\n \t\t\tWHERE\n \t\t\t\t(csl.object_id = ?) AND \n \t\t\t\t(sl.deleted = 0)\n \t\t\tORDER BY\n \t\t\t\t csl.sdatetime DESC, csl.relation_id DESC\n \t\t", array($vn_object_id));
$va_relation_ids = $qr_res->getAllFieldValues('relation_id');
$va_displays = caProcessTemplateForIDs($ps_display_template, 'ca_objects_x_storage_locations', $va_relation_ids, array('returnAsArray' => true));
$qr_res->seek(0);
$va_items = array();
while ($qr_res->nextRow()) {
$va_row = $qr_res->getRow();
$vn_relation_id = $va_row['relation_id'];
if ($va_row['sdatetime'] > $vn_current_date) {
$vs_status = 'FUTURE';
} elseif ($va_row['source_info'] == 'current') {
$vs_status = 'PRESENT';
} else {
$vs_status = 'PAST';
}
$va_items[$vn_relation_id] = array('object_id' => $va_row['object_id'], 'location_id' => $va_row['location_id'], 'display' => array_shift($va_displays), 'status' => $vs_status);
}
return $va_items;
}