本文整理汇总了PHP中Relationship::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Relationship::delete方法的具体用法?PHP Relationship::delete怎么用?PHP Relationship::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relationship
的用法示例。
在下文中一共展示了Relationship::delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testdelete
public function testdelete()
{
//unset and reconnect Db to resolve mysqli fetch exeception
global $db;
unset($db->database);
$db->checkConnection();
//execute the method and test if it works and does not throws an exception.
try {
Relationship::delete('test_test', $db);
$this->assertTrue(true);
} catch (Exception $e) {
$this->fail();
}
}
示例2: 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');
}
}
示例3: removeRelationshipMeta
/**
* Removes relationship metadata cache.
*
* Every module that has relationships defined with other modules, has this meta data cached. The cache is
* stores in 2 locations: relationships table and file system. This method clears the cache from both locations.
*
* @param string $key module whose meta cache is to be cleared.
* @param string $db database handle.
* @param string $tablename table name
* @param string $dictionary vardef for the module
* @param string $module_dir name of subdirectory where module is installed.
*
* @return Nothing
* @static
*
* Internal function, do not override.
*/
function removeRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir)
{
//load the module dictionary if not supplied.
if ((!isset($dictionary) or empty($dictionary)) && !empty($module_dir)) {
$filename = 'modules/' . $module_dir . '/vardefs.php';
if (file_exists($filename)) {
include $filename;
}
}
if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) {
$GLOBALS['log']->fatal("removeRelationshipMeta: Metadata for table " . $tablename . " does not exist");
display_notice("meta data absent for table " . $tablename . " keyed to {$key} ");
} else {
if (isset($dictionary[$key]['relationships'])) {
$RelationshipDefs = $dictionary[$key]['relationships'];
foreach ($RelationshipDefs as $rel_name) {
Relationship::delete($rel_name, $db);
}
}
}
}
示例4: testImplicitBatch_StartBatch_CloseBatch_ExpectedBatchRequest
public function testImplicitBatch_StartBatch_CloseBatch_ExpectedBatchRequest()
{
$startNode = new Node($this->client);
$endNode = new Node($this->client);
$endNode->setId(456)->useLazyLoad(false);
$rel = new Relationship($this->client);
$rel->setType('TEST')->setStartNode($startNode)->setEndNode($endNode);
$deleteNode = new Node($this->client);
$deleteNode->setId(987);
$deleteRel = new Relationship($this->client);
$deleteRel->setId(321);
$addIndexNode = new Node($this->client);
$addIndexNode->setId(654);
$removeIndexNode = new Node($this->client);
$removeIndexNode->setId(209);
$index = new Index($this->client, Index::TypeNode, 'indexname');
$request = array(array('id' => 0, 'method' => 'POST', 'to' => '/node', 'body' => null), array('id' => 1, 'method' => 'PUT', 'to' => '/node/456/properties', 'body' => array()), array('id' => 2, 'method' => 'POST', 'to' => '{0}/relationships', 'body' => array('to' => $this->endpoint . '/node/456', 'type' => 'TEST')), array('id' => 3, 'method' => 'DELETE', 'to' => '/node/987'), array('id' => 4, 'method' => 'DELETE', 'to' => '/relationship/321'), array('id' => 5, 'method' => 'POST', 'to' => '/index/node/indexname', 'body' => array('key' => 'addkey', 'value' => 'addvalue', 'uri' => $this->endpoint . '/node/654')), array('id' => 6, 'method' => 'DELETE', 'to' => '/index/node/indexname/removekey/removevalue/209'));
$return = array('code' => 200, 'data' => array(array('id' => 0, 'location' => 'http://foo:1234/db/data/node/123'), array('id' => 1), array('id' => 2, 'location' => 'http://foo:1234/db/data/relationship/789'), array('id' => 3), array('id' => 4), array('id' => 5), array('id' => 6)));
$this->setupTransportExpectation($request, $this->returnValue($return));
$batch = $this->client->startBatch();
$this->assertInstanceOf('Sgpatil\\Orientphp\\Batch', $batch);
$startNode->save();
$endNode->save();
$rel->save();
$deleteNode->delete();
$deleteRel->delete();
$index->add($addIndexNode, 'addkey', 'addvalue');
$index->remove($removeIndexNode, 'removekey', 'removevalue');
$this->assertTrue($this->client->commitBatch());
$this->assertEquals(789, $rel->getId());
$this->assertEquals(123, $startNode->getId());
}
示例5: processEntity
public function processEntity($id, $newTrans, $oldTrans)
{
//get person names so we can make sure added donations are from the right person
$sql = 'SELECT * FROM person WHERE entity_id = ?';
$stmt = $this->db->execute($sql, array($id));
if (!($donorPerson = $stmt->fetch(PDO::FETCH_ASSOC))) {
if ($this->debugMode) {
print "* Can't find Person record for donor with entity_id " . $id . "; skipping...";
}
return;
}
if ($this->debugMode) {
print "\n=== Processing entity " . $id . " (" . PersonTable::getLegalName($donorPerson) . ") ===\n";
}
$recipients = array();
//get donations from all the newly matched transactions
$newDonations = $this->getDonations($newTrans);
foreach ($newDonations as $donation) {
if (!$this->namesAreCompatible($donorPerson, $donation)) {
if ($this->debugMode) {
print "* Skipping donation with incompatible donor name: " . $donation['donor_name'] . "\n";
}
continue;
}
$cycle = $donation['cycle'];
$recipientId = $donation['recipient_id'];
if (isset($recipients[$cycle][$recipientId]['new'])) {
$recipients[$cycle][$recipientId]['new'][] = $donation;
} else {
if (!isset($recipients[$cycle])) {
$recipients[$cycle] = array();
}
$recipients[$cycle][$recipientId] = array();
$recipients[$cycle][$recipientId]['new'] = array($donation);
$recipients[$cycle][$recipientId]['old'] = array();
}
}
//get donations from all the old transactions
$oldDonations = $this->getDonations($oldTrans);
foreach ($oldDonations as $donation) {
$cycle = $donation['cycle'];
$recipientId = $donation['recipient_id'];
if (isset($recipients[$cycle][$recipientId]['old'])) {
$recipients[$cycle][$recipientId]['old'][] = $donation;
} else {
if (!isset($recipients[$cycle])) {
$recipients[$cycle] = array();
}
$recipients[$cycle][$recipientId] = array();
$recipients[$cycle][$recipientId]['old'] = array($donation);
$recipients[$cycle][$recipientId]['new'] = array();
}
}
//if there are NO already-processed matches, and no matches to remove,
//ie, if we're going from no matches to any number of matches,
//we can delete existing donation relationships for this entity
$deleteRels = false;
if (!count($oldDonations)) {
$sql = 'SELECT COUNT(*) FROM os_entity_transaction WHERE entity_id = ? AND is_processed = 1';
$stmt = $this->db->execute($sql, array($id));
if (!$stmt->fetch(PDO::FETCH_COLUMN)) {
$deleteRels = true;
}
}
if ($deleteRels) {
if ($this->debugMode) {
print "- Removing old donation relationships...\n";
}
//first get ids
$sql = 'SELECT DISTINCT r.id FROM relationship r ' . 'LEFT JOIN fec_filing f ON (f.relationship_id = r.id) ' . 'WHERE r.entity1_id = ? AND r.category_id = ? AND r.is_deleted = 0 ' . 'AND f.id IS NOT NULL';
$stmt = $this->db->execute($sql, array($id, RelationshipTable::DONATION_CATEGORY));
$relIds = $stmt->fetchAll(PDO::FETCH_COLUMN);
if (count($relIds)) {
//soft delete them
$sql = 'UPDATE relationship SET is_deleted = 1, updated_at = ? WHERE id IN (' . implode(',', $relIds) . ')';
$params = array(LsDate::getCurrentDateTime());
$this->db->execute($sql, $params);
//create modification records of the deletions
$sql = 'INSERT INTO modification (object_model, object_id, object_name, is_delete, created_at, updated_at) ' . 'VALUES ';
$params = array();
foreach ($relIds as $relId) {
$sql .= '(?, ?, ?, ?, ?, ?), ';
$now = LsDate::getCurrentDateTime();
$params = array_merge($params, array('Relationship', $relId, 'Relationship ' . $relId, true, $now, $now));
}
$sql = substr($sql, 0, strlen($sql) - 2);
$stmt = $this->db->execute($sql, $params);
}
}
//make sure the entity hasn't been deleted in the meantime!
$sql = 'SELECT id FROM entity WHERE id = ? AND is_deleted = 0';
$stmt = $this->db->execute($sql, array($id));
if (!$stmt->fetch(PDO::FETCH_COLUMN)) {
//skip to the end
$recipients = array();
}
//create filings/relationships for each cycle-recipient pair
foreach ($recipients as $cycle => $recipients) {
foreach ($recipients as $recipientId => $donations) {
//if it's a committee recipient, try to determine
//.........这里部分代码省略.........