本文整理汇总了PHP中entity_selector::add_field方法的典型用法代码示例。如果您正苦于以下问题:PHP entity_selector::add_field方法的具体用法?PHP entity_selector::add_field怎么用?PHP entity_selector::add_field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entity_selector
的用法示例。
在下文中一共展示了entity_selector::add_field方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
function setup_associated_items()
{
// populate associated entity selector from scratch
$ass_es = new entity_selector();
$ass_es->add_type($this->type_id);
if ($this->rel_direction == 'a_to_b') {
$ass_es->add_right_relationship($this->admin_page->id, $this->admin_page->rel_id);
} else {
$ass_es->add_left_relationship($this->admin_page->id, $this->admin_page->rel_id);
}
$ass_es->add_right_relationship_field('owns', 'entity', 'id', 'site_owner_id');
if ($this->rel_direction == 'a_to_b' && $this->check_is_rel_sortable()) {
$this->columns['rel_sort_order'] = true;
$ass_es->add_field('relationship', 'id', 'rel_id');
$ass_es->add_rel_sort_field($this->admin_page->id);
$ass_es->set_order('relationship.rel_sort_order ASC');
if ($this->_cur_user_has_edit_privs() && !$this->get_relationship_lock_state()) {
$this->alter_order_enable = true;
}
} else {
$ass_es->add_field('relationship', 'site', 'rel_site_id');
}
if ($this->assoc_viewer_order_by($ass_es)) {
$this->alter_order_enable = false;
}
$this->ass_vals = $ass_es->run_one();
// check sharing on associated entities
foreach ($this->ass_vals as $k => $val) {
// setup sharing value
if ($this->site_id == $val->get_value('site_owner_id')) {
$this->ass_vals[$k]->set_value('sharing', 'owns');
} else {
$this->ass_vals[$k]->set_value('sharing', $this->check_borrow_status($k));
}
}
// this verifies and updates the associated items rel_sort_order if this is an a to b relationship
if ($this->rel_direction == 'a_to_b' && $this->check_is_rel_sortable()) {
if (count($this->ass_vals) == 1 && isset($this->columns['rel_sort_order'])) {
unset($this->columns['rel_sort_order']);
}
if ($ass_es->orderby == 'relationship.rel_sort_order ASC') {
$rel_update_array = $this->validate_rel_sort_order($this->ass_vals, true);
} else {
$rel_update_array = $this->validate_rel_sort_order($this->ass_vals);
}
if (count($rel_update_array) > 0) {
foreach ($rel_update_array as $k => $v) {
update_relationship($k, array('rel_sort_order' => $v));
}
}
}
}
示例2:
function alter_values()
{
$parent = new entity_selector();
$parent->add_field('entity2', 'id', 'parent_id');
$parent->add_table('allowable_relationship2', 'allowable_relationship');
$parent->add_table('relationship2', 'relationship');
$parent->add_table('entity2', 'entity');
$parent->add_relation('entity2.id = relationship2.entity_b');
$parent->add_relation('entity.id = relationship2.entity_a');
$parent->add_relation('relationship2.type = allowable_relationship2.id');
$parent->add_relation('allowable_relationship2.name LIKE "%parent%"');
$parent->set_order('sortable.sort_order');
$this->es->swallow($parent);
$this->remove_column('id');
}
示例3: current
function _get_max_sort_order_value($page_id)
{
$es = new entity_selector();
$es->add_type(id_of('image'));
$es->add_right_relationship($page_id, relationship_id_of('minisite_page_to_image'));
$es->add_field('relationship', 'id', 'rel_id');
$es->add_rel_sort_field($page_id);
$es->set_order('relationship.rel_sort_order DESC');
$es->set_num(1);
$images = $es->run_one();
if (!empty($images)) {
$image = current($images);
if ($image->get_value('rel_sort_order')) {
return $image->get_value('rel_sort_order');
}
}
return 0;
}
示例4: get_relationships_to_update
function get_relationships_to_update($left_side_entity_type, $right_side_entity_type, $relationship_type, $left_side_relation_limiter, $ordering)
{
$es = new entity_selector();
$es->add_type(id_of($left_side_entity_type));
if (!empty($left_side_relation_limiter)) {
$es->add_relation($left_side_relation_limiter);
}
$result = $es->run_one();
foreach ($result as $entity) {
if ($entity->has_left_relation_of_type(relationship_id_of($relationship_type))) {
$owns_entity = $entity->get_owner();
$site_id = !empty($owns_entity) ? $owns_entity->id() : '';
$es2 = new entity_selector($site_id);
$es2->add_type(id_of($right_side_entity_type));
$es2->set_sharing('owns,borrows');
$es2->add_right_relationship($entity->id(), relationship_id_of($relationship_type));
if (!empty($site_id)) {
$es2->add_field('ar', 'name', 'sharing');
}
$es2->add_field('relationship', 'id', 'rel_id');
if (!empty($ordering)) {
$es2->set_order($ordering);
}
//echo '<hr> '.$es2->get_one_query() . '<hr/>';
$result2 = $es2->run_one();
$sort_order = 1;
if (is_array($result2)) {
foreach ($result2 as $entity) {
$update_array[$entity->get_value('rel_id')] = $sort_order;
$sort_order++;
}
}
}
}
if (isset($update_array) && count($update_array) > 0) {
return $update_array;
} else {
trigger_error('Could not find anything to update - check to make sure you have entered a valid left and right side entity, and relationship type');
die;
}
}
示例5:
function get_images_in_new_order($page_id)
{
$es = new entity_selector();
$es->add_type(id_of('image'));
$es->add_right_relationship($page_id, relationship_id_of('minisite_page_to_image'));
$es->add_rel_sort_field($page_id, relationship_id_of('minisite_page_to_image'), 'rel_sort_order');
$es->add_field('relationship', 'id', 'rel_id');
$es->set_order('rel_sort_order ASC, dated.datetime ASC, meta.description ASC, entity.id ASC');
return $es->run_one();
}
示例6: entity
/**
* prep_for_run returns the array describing which relationships need to be updated, and also verifies that the entity that is
* being moved is in the same row position it was prior to the request (gracefully handles double clicks and the like)
*
* @return mixed array describing new sort orders according to relationship id, or false
*/
function prep_for_run()
{
$e = new entity($this->entity_id);
$type_id = $e->get_value('type');
// performs an appropriate entity selection - populates class variables with specifics for run method.
$es = new entity_selector($this->site_id);
$es->add_type($type_id);
$es->set_sharing('owns,borrows');
$es->add_field('relationship', 'id', 'relationship_id');
$es->add_right_relationship($this->left_entity_id, $this->al_relationship_id);
$es->add_rel_sort_field($this->left_entity_id);
if ($this->direction == 'moveup') {
$es->set_order('rel_sort_order DESC');
} else {
$es->set_order('rel_sort_order ASC');
}
$result = $es->run_one();
$resultcount = count($result);
$read_next = false;
$rowcounter = 0;
foreach ($result as $k => $v) {
if ($read_next == true) {
$new_rel_sort_order = $v->get_value('rel_sort_order');
$relationship_id_2 = $v->get_value('relationship_id');
break;
} elseif ($k == $this->entity_id) {
if ($this->direction == 'moveup' && $this->row_id == $resultcount - $rowcounter || $this->direction == 'movedown' && $this->row_id == $rowcounter + 1) {
$old_rel_sort_order = $v->get_value('rel_sort_order');
$relationship_id_1 = $v->get_value('relationship_id');
$read_next = true;
} else {
trigger_error('There was a problem modifying the relationship sort order - the entity being moved does not have the same location as when the request was initiated. This can happen from multiple clicks or when multiple people are modifying the sort order.');
return false;
}
} else {
unset($result[$k]);
$rowcounter++;
}
}
if (is_numeric($relationship_id_1) && is_numeric($relationship_id_2) && is_numeric($new_rel_sort_order) && is_numeric($old_rel_sort_order)) {
return array($relationship_id_1 => $new_rel_sort_order, $relationship_id_2 => $old_rel_sort_order);
} else {
return false;
}
}