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


PHP Entity::sync方法代码示例

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


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

示例1: testEntity

 function testEntity()
 {
     global $_PA;
     // Dal::register_query_callback("explain_query");
     // see if our test entity already exists
     $entity = Entity::load("PHPUnit", "TestEntity", "#1");
     $this->assertNull($entity, "we shouldn't have any Entites in the service PHPUnit at this point.");
     $myEntity = new TestEntity('#1');
     echo "sync #1\n";
     Entity::sync($myEntity);
     // create a second
     $myEntity2 = new TestEntity('#2');
     echo "sync #2\n";
     Entity::sync($myEntity2);
     // modify #1
     $myEntity->attributes['ThreeAttribute'] = array('value' => "Baz");
     Entity::sync($myEntity);
     // remove an attribute from #2
     unset($myEntity2->attributes['OneAttribute']);
     Entity::sync($myEntity2);
     $myEntity3 = new TestEntity('#3');
     Entity::sync($myEntity3);
     $myEntity4 = new TestEntity('#4');
     $myEntity4->attributes['ThreeAttribute'] = array('value' => "Baz");
     $myEntity4->attributes['fourAttribute'] = array('value' => "4");
     Entity::sync($myEntity4);
     // test attribute search
     // Dal::register_query_callback("explain_query");
     $foundEntities = Entity::search(array('entity_service' => 'PHPUnit', 'entity_type' => 'TestEntity'), array('OneAttribute' => 'F', 'TwoAttribute' => 'b', 'ThreeAttribute' => 'b', 'FourAttribute' => '4'));
     // Dal::unregister_query_callback("explain_query");
     echo "\nfound " . count($foundEntities) . " entities by attribute search:\n";
     foreach ($foundEntities as $i => $e) {
         echo "entity: '{$e['entity_service']}:{$e['entity_type']}:{$e['entity_id']}\n";
     }
     // Dal::register_query_callback("explain_query");
     $foundEntities = Entity::search(array(), array('FourAttribute' => '4'));
     // Dal::unregister_query_callback("explain_query");
     echo "\nfound " . count($foundEntities) . " entities by attribute search:\n";
     foreach ($foundEntities as $i => $e) {
         echo "entity: '{$e['entity_service']}:{$e['entity_type']}:{$e['entity_id']}\n";
     }
     $testEntities = Entity::search(array('entity_service' => 'PHPUnit', 'entity_type' => 'TestEntity'));
     echo "\nfound " . count($testEntities) . " test entities:\n";
     // load test entities
     foreach ($testEntities as $i => $e) {
         echo "entity: '{$e['entity_service']}:{$e['entity_type']}:{$e['entity_id']}\n";
         // print_r(Entity::load($e['entity_service'], $e['entity_type'], $e['entity_id'])); echo "\n";
     }
     // clean up test entities
     foreach ($testEntities as $i => $e) {
         Entity::delete($e['entity_service'], $e['entity_type'], $e['entity_id']);
     }
     // test again
     $testEntities = Entity::search(array('entity_service' => 'PHPUnit'));
     $this->assertEquals(count($testEntities), 0, "There should no longer be any Entities in the PHPUnit service.");
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:56,代码来源:EntityTest.php

示例2: sync

 public static function sync($entity)
 {
     $_ent = Entity::load($entity->entity_service, $entity->entity_type, $entity->entity_id);
     if (empty($_ent)) {
         self::update_user_points($entity->attributes);
     } else {
         self::update_user_points($entity->attributes, $_ent->attributes);
     }
     parent::sync($entity);
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:10,代码来源:PointsEntity.php

示例3: sync

 public static function sync($data)
 {
     $entity = (object) array('entity_service' => 'typedGroup', 'entity_type' => $data['type'], 'entity_id' => $data['group_id'], 'entity_name' => $data['name'], 'attributes' => $data);
     parent::sync($entity);
     // also update the group that this corresponds to
     $g = new Group();
     try {
         $g->load((int) $data['group_id']);
         $g->group_type = 'typedgroup';
         $g->save();
     } catch (PAException $e) {
         throw $e;
     }
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:14,代码来源:TypedGroupEntity.php


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