本文整理汇总了PHP中Relationship类的典型用法代码示例。如果您正苦于以下问题:PHP Relationship类的具体用法?PHP Relationship怎么用?PHP Relationship使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Relationship类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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";
}
}
}
示例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));
}
示例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;
}
示例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());
}
}
示例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;
}
示例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');
}
}