• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Relationship类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: UpdateLinkedRelationship

 /**
  * Given this relationship record, this will update the "linked" relationship record with the same stats and details.
  * 
  * This will CREATE the Linked Relationship record if none yet exists.
  * 
  */
 public function UpdateLinkedRelationship()
 {
     $objPerson = $this->Person;
     $objRelatedPerson = $this->RelatedToPerson;
     $objLinkedRelationship = Relationship::LoadByPersonIdRelatedToPersonId($objRelatedPerson->Id, $objPerson->Id);
     if (!$objLinkedRelationship) {
         $objLinkedRelationship = new Relationship();
         $objLinkedRelationship->Person = $objRelatedPerson;
         $objLinkedRelationship->RelatedToPerson = $objPerson;
     }
     // Figure out the "Opposite" relationship to create
     switch ($this->intRelationshipTypeId) {
         case RelationshipType::Child:
             $objLinkedRelationship->RelationshipTypeId = RelationshipType::Parental;
             break;
         case RelationshipType::Parental:
             $objLinkedRelationship->RelationshipTypeId = RelationshipType::Child;
             break;
         case RelationshipType::Sibling:
             $objLinkedRelationship->RelationshipTypeId = RelationshipType::Sibling;
             break;
         case RelationshipType::Grandchild:
             $objLinkedRelationship->RelationshipTypeId = RelationshipType::Grandparent;
             break;
         case RelationshipType::Grandparent:
             $objLinkedRelationship->RelationshipTypeId = RelationshipType::Grandchild;
             break;
         default:
             throw new Exception('Invalid Relationship Type Id: ' . $intRelationshipTypeId);
     }
     $objLinkedRelationship->Save();
 }
开发者ID:alcf,项目名称:chms,代码行数:38,代码来源:Relationship.class.php


示例2: getMarriages

 function getMarriages(&$search, $limit = 0)
 {
     global $tblprefix, $err_marriage, $currentRequest;
     $res = array();
     $query = "SELECT DISTINCT CONCAT_WS('-', YEAR(NOW()), LPAD(MONTH(e.date1), 2, '0'), LPAD(DAYOFMONTH(e.date1), 2, '0')) AS fake_marriage, " . "DATE_FORMAT(e.date1, " . $currentRequest->datefmt . ") AS DOM, e.date1, " . PersonDetail::getFields("groom", "ng", "bg", "dg") . "," . PersonDetail::getFields("bride", "nb", "bb", "db") . ", sp.dissolve_date, sp.dissolve_reason," . " DATE_FORMAT(sp.dissolve_date, " . $currentRequest->datefmt . ") AS DOD, e.event_id " . " FROM " . $tblprefix . "event e" . " JOIN " . $tblprefix . "spouses sp ON sp.event_id = e.event_id" . " LEFT JOIN " . $tblprefix . "people bride ON sp.bride_id = bride.person_id " . " LEFT JOIN " . $tblprefix . "people groom ON sp.groom_id = groom.person_id " . PersonDetail::getJoins("LEFT", "groom", "ng", "bg", "dg") . PersonDetail::getJoins("LEFT", "bride", "nb", "bb", "db");
     // if the user is not logged in, only show people pre $restrictdate
     $query .= $this->addPersonRestriction(" WHERE ", "bb", "db");
     $query .= $this->addPersonRestriction(" AND ", "bg", "dg");
     $query .= " AND (e.etype = " . BANNS_EVENT . " OR e.etype = " . MARRIAGE_EVENT . ") ";
     if ($limit > 0) {
         $query .= " HAVING fake_marriage >= now() AND fake_marriage <= DATE_ADD(NOW(), INTERVAL {$limit} DAY) ORDER BY fake_marriage";
     }
     $this->addLimit($search, $query);
     $result = $this->runQuery($query, $err_marriage);
     $search->numResults = 0;
     while ($row = $this->getNextRow($result)) {
         $rel = new Relationship();
         $rel->person->loadFields($row, L_HEADER, "groom_");
         $rel->person->name->loadFields($row, "ng_");
         $rel->relation->loadFields($row, L_HEADER, "bride_");
         $rel->relation->name->loadFields($row, "nb_");
         $rel->loadFields($row);
         $rel->marriage_date = $row["date1"];
         $rel->dom = $row["DOM"];
         $search->numResults++;
         $res[] = $rel;
     }
     $this->freeResultSet($result);
     $search->results = $res;
 }
开发者ID:redbugz,项目名称:rootstech2013,代码行数:30,代码来源:RelationsDAO.php


示例3: test_specified_foreign_key_in_constructor_takes_precedence

 public function test_specified_foreign_key_in_constructor_takes_precedence()
 {
     $factory = M::mock('AdamWathan\\Faktory\\Factory');
     $relationship = new Relationship('Foo\\Bar\\Post', $factory, 'post');
     $expected = 'post';
     $this->assertSame($expected, $relationship->getForeignKey());
 }
开发者ID:adamwathan,项目名称:faktory,代码行数:7,代码来源:RelationshipTest.php


示例4: setup_edit

function setup_edit()
{
    $rel = new Relationship();
    $rel->setFromRequest();
    if (!$rel->relation->person_id) {
        $rel->relation->person_id = -1;
    }
    $pdao = getPeopleDAO();
    if ($rel->person->person_id > 0) {
        $dao = getRelationsDAO();
        $dao->getRelationshipDetails($rel);
        if ($rel->numResults > 0) {
            $ret = $rel->results[0];
            $pdao->getParents($ret->relation);
        }
    } else {
        $ret = $rel;
    }
    $pdao->getParents($ret->person);
    $dao = getEventDAO();
    $e = new Event();
    $e->event_id = $ret->event->event_id;
    $dao->getEvents($e, Q_REL, true);
    if ($e->numResults == 0) {
        $e = new Event();
        $e->type = MARRIAGE_EVENT;
        $ret->event = $e;
    } else {
        $ret->event = $e->results[0];
    }
    $ret->event->person->person_id = 'null';
    return $ret;
}
开发者ID:redbugz,项目名称:rootstech2013,代码行数:33,代码来源:editForm.php


示例5: processEventCriteria

 /**
  * That method decode the event criteria string and insert into an array when
  * the expType is MODULE for evaluate purpose.
  * @param string eventCriteria
  * @param object event
  * @return array
  * @codeCoverageIgnore
  */
 private function processEventCriteria($eventCriteria, $event)
 {
     $criteria = json_decode($eventCriteria);
     $resultArray = array();
     if (is_array($criteria)) {
         foreach ($criteria as $token) {
             if ($token->expType == 'MODULE') {
                 $tmpObj = new stdClass();
                 $tmpObj->pro_id = $event->pro_id;
                 $tmpBean = BeanFactory::getBean('pmse_BpmProcessDefinition');
                 //$this->beanFactory->getBean('BpmProcessDefinition');
                 $tmpBean->retrieve_by_string_fields(array('id' => $tmpObj->pro_id));
                 $tmpObj->rel_process_module = $tmpBean->pro_module;
                 $tmpObj->rel_element_id = $event->evn_id;
                 $tmpObj->rel_element_type = $event->evn_type . '_EVENT';
                 $tmpObj->rel_element_relationship = $token->expModule;
                 if ($tmpObj->rel_process_module == $token->expModule) {
                     $tmpObj->rel_element_module = $token->expModule;
                 } else {
                     // @codeCoverageIgnoreStart
                     $relBean = new Relationship();
                     $tmpObj->rel_element_module = $relBean->get_other_module($token->expModule, $tmpObj->rel_process_module, $this->db);
                     // @codeCoverageIgnoreEnd
                 }
                 $resultArray[] = $tmpObj;
             }
         }
     }
     return $resultArray;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:38,代码来源:PMSEEventDefinition.php


示例6: setUp

 public function setUp()
 {
     $this->client = $this->getMock('Everyman\\Neo4j\\Client', array(), array(), '', false);
     $this->path = new Path($this->client);
     $rel = new Relationship($this->client);
     $rel->setStartNode(new Node($this->client));
     $rel->setEndNode(new Node($this->client));
     $this->path->appendRelationship($rel);
     $this->rels[0] = $rel;
     $rel = new Relationship($this->client);
     $rel->setStartNode(new Node($this->client));
     $rel->setEndNode(new Node($this->client));
     $this->path->appendRelationship($rel);
     $this->rels[1] = $rel;
     $node = new Node($this->client);
     $this->path->appendNode($node);
     $this->nodes[0] = $node;
     $node = new Node($this->client);
     $this->path->appendNode($node);
     $this->nodes[1] = $node;
     $node = new Node($this->client);
     $this->path->appendNode($node);
     $this->nodes[2] = $node;
     $node = new Node($this->client);
     $this->path->appendNode($node);
     $this->nodes[3] = $node;
 }
开发者ID:jadz,项目名称:neo4j-php,代码行数:27,代码来源:PathTest.php


示例7: addRelationship

 public function addRelationship(Relationship $relationship)
 {
     if ($relationship->getOneEntity() != $this and $relationship->getOtherEntity() != $this) {
         throw new Exception("Invalid argument: cannot add relationship with entity '" . $relationship->getOtherEntity()->getName() . "' as a relationship of entity '{$this->name}'.");
     }
     $this->relationships[] = $relationship;
 }
开发者ID:RobBosman,项目名称:bransom.RestServer-PHP,代码行数:7,代码来源:Entity.class.php


示例8: addLobbyFilingToRelationship

 static function addLobbyFilingToRelationship(Relationship $relationship, LobbyFiling $filing)
 {
     $generatedAmount = self::getFecFilingAmountSumByRelationshipId($relationship->id) + $filing->amount;
     $relationship->amount = max($generatedAmount, $relationship->amount);
     $relationship->updateDateRange($filing->start_date);
     $relationship->filings = $this->getLobbyFilingsByRelationshipId($relationship->id)->count() + 1;
     $relationship->save();
     $filing->relationship_id = $relationship->id;
     $filing->save();
 }
开发者ID:silky,项目名称:littlesis,代码行数:10,代码来源:Lobbying.class.php


示例9: buildRelationship

 /**
  * Builds the relationship object based on user schema
  *
  * @param  array        $relInfo relationship info from user schema
  * @return Relationship
  */
 public function buildRelationship(array $relInfo)
 {
     $relationship = new Relationship($relInfo['start'], $relInfo['end'], $relInfo['type']);
     $relationship->setCardinality($relInfo['mode']);
     if (isset($relInfo['properties'])) {
         foreach ($relInfo['properties'] as $name => $info) {
             $property = $this->buildRelationshipProperty($name, $info);
             $relationship->addProperty($property);
         }
     }
     return $relationship;
 }
开发者ID:neoxygen,项目名称:neogen,代码行数:18,代码来源:GraphSchemaBuilder.php


示例10: execute

 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($options['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $q = EntityTable::getByExtensionQuery(array('Person', 'ElectedRepresentative'))->addWhere('summary like ? OR summary like ? OR summary like ? OR summary like ? OR summary like ? OR summary like ? OR summary like ? OR summary like ? OR summary like ?', array('(daughter%', '(son%', '(father%', '(mother%', '(cousin%', '(husband%', '(wife%', '(brother%', '(sister%'))->orderBy('person.name_last');
     $members = $q->execute();
     foreach ($members as $member) {
         if (preg_match('/\\([^\\)]*\\)/isu', $member->summary, $match)) {
             echo $member->name . ":\n";
             if (preg_match_all('/(brother|sister|daughter|mother|father|wife|husband|cousin)\\sof\\s+([^\\;\\)\\,]*)(\\;|\\)|\\,)/isu', $match[0], $matches, PREG_SET_ORDER)) {
                 foreach ($matches as $m) {
                     echo "\t\t" . $m[1] . ' : of : ' . $m[2] . "\n";
                     $m[2] = str_replace('.', '', $m[2]);
                     $parts = LsString::split($m[2]);
                     $q = EntityTable::getByExtensionQuery(array('Person', 'ElectedRepresentative'));
                     foreach ($parts as $part) {
                         $q->addWhere('e.name like ?', '%' . $part . '%');
                     }
                     $people = $q->execute();
                     $family = array();
                     foreach ($people as $person) {
                         echo "\t\t\t\t" . $person->name . "\n";
                         if ($person->id != $member->id) {
                             $family[] = $person;
                         }
                     }
                     if (count($family) == 1) {
                         $q = LsDoctrineQuery::create()->from('Relationship r')->where('(r.entity1_id = ? or r.entity2_id =?) and (r.entity1_id = ? or r.entity2_id = ?)', array($member->id, $member->id, $person->id, $person->id));
                         if (!$q->count()) {
                             if ($description2 = FamilyTable::getDescription2($m[1], $family[0]->Gender->id)) {
                                 $relationship = new Relationship();
                                 $relationship->setCategory('Family');
                                 $relationship->Entity1 = $member;
                                 $relationship->Entity2 = $person;
                                 $relationship->description1 = $m[1];
                                 $relationship->description2 = $description2;
                                 $relationship->save();
                                 $ref = LsQuery::getByModelAndFieldsQuery('Reference', array('object_model' => 'Entity', 'object_id' => $member->id, 'name' => 'Congressional Biographical Directory'))->fetchOne();
                                 if ($ref) {
                                     $relationship->addReference($ref->source, null, null, $ref->name, $ref->source_detail, $ref->publication_date);
                                 }
                                 echo "-------------------------------added relationship\n";
                             }
                         }
                     }
                 }
             }
             echo "\n";
         }
     }
 }
开发者ID:silky,项目名称:littlesis,代码行数:52,代码来源:CongressIsAFamilyTask.class.php


示例11: testDelete_PropertyContainerEntities_ReturnsIntegerOperationIndex

 public function testDelete_PropertyContainerEntities_ReturnsIntegerOperationIndex()
 {
     $nodeA = new Node($this->client);
     $nodeA->setId(123);
     $nodeB = new Node($this->client);
     $nodeB->setId(456);
     $nodeC = new Node($this->client);
     $rel = new Relationship($this->client);
     $rel->setId(987)->setStartNode($nodeA)->setEndNode($nodeB);
     $this->assertEquals(0, $this->batch->delete($nodeA));
     $this->assertEquals(1, $this->batch->delete($nodeB));
     $this->assertEquals(2, $this->batch->delete($nodeC));
     $this->assertEquals(3, $this->batch->delete($rel));
 }
开发者ID:MobilityMaster,项目名称:neo4jphp,代码行数:14,代码来源:BatchTest.php


示例12: Query

 /**
  * Gets the classes whose objects the user can execute certain action
  *
  * @param $action object - The action that the user should be allowed to do
  * @param $user User - The user that holds de permissions
  * @return Array - an array of class objects
  */
 function &findByPermission($action, $user)
 {
     $classQuery = new Query("Class");
     // Navigate relationships
     $folderClassQuery =& $classQuery->queryRelationedClass("FolderClass");
     $permissionQuery =& $folderClassQuery->queryRelationedClass("Permission");
     $actionQuery =& $permissionQuery->queryRelationedClass("Action", Relationship::ManyToOneType());
     $roleQuery =& $permissionQuery->queryRelationedClass("Role", Relationship::ManyToOneType());
     $roleUserQuery =& $roleQuery->queryRelationedClass("RoleUser");
     $userQuery =& $roleUserQuery->queryRelationedClass("User", Relationship::ManyToOneType());
     // Criterias
     $criteriaGroup = new CriteriaGroup();
     $actionCriteria = new Criteria($actionQuery, "action", $action->getAction());
     $userCriteria = new Criteria($userQuery, "ID", $user->getId());
     $criteriaGroup->addCriterion($actionCriteria);
     $criteriaGroup->addCriterion($userCriteria);
     $classQuery->setCriterion($criteriaGroup);
     // sorting
     $order = new Order($classQuery, "title", "ASC");
     $classQuery->addOrder($order);
     // Execute the query
     $recordset =& $classQuery->execute();
     $array = $this->mapAll($recordset);
     return $array;
 }
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:32,代码来源:baseClassMapper.php


示例13: actionProfile

 public function actionProfile()
 {
     try {
         $is_followed = FALSE;
         $request = Yii::app()->request;
         if ($request->getQuery('ref_api') == Yii::app()->params['REF_API']) {
             $user_id = $request->getQuery('user_id');
         } else {
             if ($request->getQuery('ref_web') == 'ref_web') {
                 $user_id = $request->getQuery('user_id');
             } else {
                 $user_id = Yii::app()->session['user_id'];
             }
         }
         $data = User::model()->getProfile($user_id);
         $posts = Posts::model()->getPostByUserForWeb($user_id);
         if ($user_id != Yii::app()->session['user_id']) {
             $check_block = Relationship::model()->findByAttributes(array('user_id_2' => Yii::app()->session['user_id'], 'user_id_1' => $user_id, 'user_type' => 'USER'));
             $is_followed = User::model()->isFollowedByUser(Yii::app()->session['user_id'], $user_id, 'USER');
             if ($check_block) {
                 return;
             }
         }
         $arr = array('profile' => $data, 'posts' => $posts['data'], 'pages' => $posts['pages'], 'is_followed' => $is_followed);
         if ($request->getQuery('ref_api') == Yii::app()->params['REF_API']) {
             ResponseHelper::JsonReturnSuccess($arr, 'Success');
         } else {
             $this->render('profile', $arr);
         }
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
开发者ID:huynt57,项目名称:fashion,代码行数:33,代码来源:UserController.php


示例14: action_addToProspectList

 protected function action_addToProspectList()
 {
     global $beanList;
     require_once 'modules/Relationships/Relationship.php';
     require_once 'modules/ProspectLists/ProspectList.php';
     $prospectList = new ProspectList();
     $prospectList->retrieve($_REQUEST['prospect_id']);
     $module = new $beanList[$this->bean->report_module]();
     $key = Relationship::retrieve_by_modules($this->bean->report_module, 'ProspectLists', $GLOBALS['db']);
     if (!empty($key)) {
         $sql = $this->bean->build_report_query();
         $result = $this->bean->db->query($sql);
         $beans = array();
         while ($row = $this->bean->db->fetchByAssoc($result)) {
             if (isset($row[$module->table_name . '_id'])) {
                 $beans[] = $row[$module->table_name . '_id'];
             }
         }
         if (!empty($beans)) {
             foreach ($prospectList->field_defs as $field => $def) {
                 if ($def['type'] == 'link' && !empty($def['relationship']) && $def['relationship'] == $key) {
                     $prospectList->load_relationship($field);
                     $prospectList->{$field}->add($beans);
                 }
             }
         }
     }
     die;
 }
开发者ID:isrealconsulting,项目名称:ic-suite,代码行数:29,代码来源:controller.php


示例15: rejectRelationship

 private function rejectRelationship($r)
 {
     if ($this->registry->getObject('authenticate')->isLoggedIn()) {
         require_once FRAMEWORK_PATH . 'models/relationship.php';
         $relationship = new Relationship($this->registry, $r, 0, 0, 0, 0);
         if ($relationship->getUserB() == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
             // we can reject this!
             $relationship->delete();
             $this->registry->errorPage('Relationship rejected', 'Thank you for rejecting the relationship');
         } else {
             $this->registry->errorPage('Invalid request', 'You are not authorized to reject that request');
         }
     } else {
         $this->registry->errorPage('Please login', 'Please login to reject this connection');
     }
 }
开发者ID:simontakite,项目名称:cookbooks,代码行数:16,代码来源:controller.php


示例16: RelationshipHandler

 function RelationshipHandler($db, $base_module = "")
 {
     $this->db = $db;
     $this->base_module = $base_module;
     parent::__construct();
     //end function RelationshipHandler
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:7,代码来源:RelationshipHandler.php


示例17: add

 public function add($user_follow, $user_followed, $type)
 {
     $check = Relationship::model()->findAllByAttributes(array('user_id_1' => $user_follow, 'user_id_2' => $user_followed));
     $check_2 = Relationship::model()->findAllByAttributes(array('user_id_2' => $user_follow, 'user_id_1' => $user_followed));
     $check_3 = Follow::model()->findByAttributes(array('user_follow' => $user_follow, 'user_followed' => $user_followed));
     if ($check || $check_2 || $check_3 || $user_followed == Yii::app()->session['user_id']) {
         return FALSE;
     }
     $model = new Follow();
     $model->user_follow = $user_follow;
     $model->user_followed = $user_followed;
     $model->created_at = time();
     $model->update_at = time();
     $model->type = $type;
     $user_follow_data = User::model()->findByPk($user_follow);
     $user_followed_data = User::model()->findByPk($user_followed);
     if ($user_follow != Yii::app()->session['user_id']) {
         $arr_noti = array('user_id' => $user_follow, 'content' => "{$user_follow_data->username} vừa theo dõi bạn", 'type' => 'follow', 'recipient_id' => $user_followed_data->id, 'url' => Yii::app()->createAbsoulteUrl('user/profile', array('user_id' => $user_follow_data->id, 'ref' => 'noti')));
         Notifications::model()->add($arr_noti);
     }
     if ($model->save(FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:huynt57,项目名称:fashion,代码行数:25,代码来源:Follow.php


示例18: execute

 protected function execute($arguments = array(), $options = array())
 {
     //set start time
     $time = microtime(true);
     //connect to raw database
     $this->init($arguments, $options);
     //find political candidates who don't have political party
     $sql = 'SELECT e.id,e.name,pc.crp_id FROM entity e LEFT JOIN political_candidate pc ON pc.entity_id = e.id LEFT JOIN person p on p.entity_id = e.id WHERE p.party_id IS NULL AND pc.crp_id IS NOT NULL AND pc.crp_id <> "" and e.is_deleted = 0 LIMIT ' . $options['limit'];
     $stmt = $this->db->execute($sql);
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     foreach ($rows as $row) {
         echo 'processing ' . $row['name'] . " ::\n";
         $sql = 'SELECT name,party,candidate_id FROM os_candidate WHERE candidate_id = ?';
         $stmt = $this->rawDb->execute($sql, array($row['crp_id']));
         $matches = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $sql = 'select e.id from entity e limit 1';
         $stmt = $this->db->execute($sql);
         $stmt->fetchAll(PDO::FETCH_ASSOC);
         if (count($matches)) {
             $party_id = $this->processParty($matches[0]['party']);
             echo "\t match found: " . $matches[0]['name'] . ', with party ' . $party_id . "/" . $matches[0]['party'] . "\n";
             if ($party_id && !$options['test_mode']) {
                 $db = $this->databaseManager->getDatabase('main');
                 $this->db = Doctrine_Manager::connection($db->getParameter('dsn'), 'main');
                 $person = Doctrine::getTable('Person')->findOneByEntityId($row['id']);
                 if (!$person) {
                     die;
                 }
                 $person->party_id = $party_id;
                 $person->save();
                 echo "\t\t current political party saved as " . $person->party_id . "\n";
                 $q = LsDoctrineQuery::create()->from('Relationship r')->where('r.entity1_id = ? and r.entity2_id = ? and r.category_id = ?', array($row['id'], $party_id, 3));
                 if (!$q->fetchOne()) {
                     $r = new Relationship();
                     $r->entity1_id = $row['id'];
                     $r->entity2_id = $party_id;
                     $r->setCategory('Membership');
                     $r->is_current = true;
                     $r->save();
                     echo "\t\t party membership saved\n";
                 }
             }
         } else {
             echo "\t no matches found\n";
         }
     }
 }
开发者ID:silky,项目名称:littlesis,代码行数:47,代码来源:CleanupPoliticalPartiesTask.class.php


示例19: testCommitBatch_AddToIndex_NoEntitiesExist_Success_ReturnsTrue

 public function testCommitBatch_AddToIndex_NoEntitiesExist_Success_ReturnsTrue()
 {
     $nodeA = new Node($this->client);
     $nodeB = new Node($this->client);
     $rel = new Relationship($this->client);
     $rel->setType('TEST')->setStartNode($nodeA)->setEndNode($nodeB);
     $index = new Index($this->client, Index::TypeRelationship, 'indexname');
     $request = array(array('id' => 2, 'method' => 'POST', 'to' => '/node', 'body' => null), array('id' => 3, 'method' => 'POST', 'to' => '/node', 'body' => null), array('id' => 1, 'method' => 'POST', 'to' => '{2}/relationships', 'body' => array('to' => '{3}', 'type' => 'TEST')), array('id' => 0, 'method' => 'POST', 'to' => '/index/relationship/indexname', 'body' => array('key' => 'somekey', 'value' => 'somevalue', 'uri' => '{1}')));
     $return = array('code' => 200, 'data' => array(array('id' => 2, 'location' => 'http://foo:1234/db/data/node/123'), array('id' => 3, 'location' => 'http://foo:1234/db/data/node/456'), array('id' => 1, 'location' => 'http://foo:1234/db/data/relationship/789'), array('id' => 0)));
     $this->batch->addToIndex($index, $rel, 'somekey', 'somevalue');
     $this->setupTransportExpectation($request, $this->returnValue($return));
     $result = $this->client->commitBatch($this->batch);
     $this->assertTrue($result);
     $this->assertEquals(123, $nodeA->getId());
     $this->assertEquals(456, $nodeB->getId());
     $this->assertEquals(789, $rel->getId());
 }
开发者ID:pin-cnx,项目名称:orientdb-php,代码行数:17,代码来源:Client_Batch_IndexTest.php


示例20: Link

 /**
  * @param string    $_rel_name   use this relationship key.
  * @param SugarBean $_bean       reference of the bean that instantiated this class.
  * @param array     $fieldDef    vardef entry for the field.
  * @param string    $_table_name optional, fetch from the bean's table name property.
  * @param string    $_key_name   optional, name of the primary key column for _table_name
  */
 public function Link($_rel_name, SugarBean &$_bean, $fieldDef, $_table_name = '', $_key_name = '')
 {
     global $dictionary;
     require_once DOCROOT . "modules/TableDictionary.php";
     Log::debug("Link Constructor, relationship name: [{$_rel_name}], Table name [{$_table_name}], Key name [{$_key_name}]");
     $this->_relationship_name = $_rel_name;
     $this->relationship_fields = !empty($fieldDef['rel_fields']) ? $fieldDef['rel_fields'] : [];
     $this->_bean =& $_bean;
     $this->_relationship = new Relationship();
     //$this->_relationship->retrieve_by_string_fields(array('relationship_name'=>$this->_relationship_name));
     $this->_relationship->retrieve_by_name($this->_relationship_name);
     $this->_db = DBManagerFactory::getInstance();
     // Following behavior is tied to a property(ignore_role) value in the vardef.
     // It alters the values of 2 properties, ignore_role_filter and add_distinct.
     // the property values can be altered again before any requests are made.
     if (!empty($fieldDef) && is_array($fieldDef)) {
         if (array_key_exists('ignore_role', $fieldDef)) {
             if ($fieldDef['ignore_role'] == true) {
                 $this->ignore_role_filter = true;
                 $this->add_distinct = true;
             }
         }
     }
     $this->_bean_table_name = !empty($_table_name) ? $_table_name : $_bean->getTableName();
     if (!empty($key_name)) {
         $this->_bean_key_name = $_key_name;
     } else {
         if ($this->_relationship->lhs_table != $this->_relationship->rhs_table) {
             if ($_bean->table_name == $this->_relationship->lhs_table) {
                 $this->_bean_key_name = $this->_relationship->lhs_key;
             }
             if ($_bean->table_name == $this->_relationship->rhs_table) {
                 $this->_bean_key_name = $this->_relationship->rhs_key;
             }
         }
     }
     if ($this->_relationship->lhs_table == $this->_relationship->rhs_table && isset($fieldDef['side']) && $fieldDef['side'] == 'right') {
         $this->_swap_sides = true;
     }
     if (!empty($fieldDef['rhs_key_override'])) {
         $this->_rhs_key_override = true;
     }
     if (!empty($fieldDef['bean_filter_field'])) {
         $this->_bean_filter_field = $fieldDef['bean_filter_field'];
     }
     //default to id if not set.
     if (empty($this->_bean_key_name)) {
         $this->_bean_key_name = 'id';
     }
     Log::debug("Link Constructor, _bean_table_name: [{$this->_bean_table_name}], _bean_key_name: [{$this->_bean_key_name}]");
     if (!empty($this->_relationship->id)) {
         Log::debug("Link Constructor, relationship record found.");
     } else {
         Log::debug("Link Constructor, No relationship record.");
     }
 }
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:63,代码来源:Link.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Release类代码示例发布时间:2022-05-23
下一篇:
PHP Relation类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap