本文整理汇总了PHP中Relation::isCombination方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::isCombination方法的具体用法?PHP Relation::isCombination怎么用?PHP Relation::isCombination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relation
的用法示例。
在下文中一共展示了Relation::isCombination方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DelPair
function DelPair($relationName, $srcConcept, $srcAtom, $tgtConcept, $tgtAtom)
{
if (func_num_args() != 5) {
throw new Exception("Wrong number of arguments supplied for function DelPair(): " . func_num_args() . " arguments", 500);
}
Notifications::addLog("DelPair({$relationName},{$srcConcept},{$srcAtom},{$tgtConcept},{$tgtAtom})", 'ExecEngine');
try {
$database = Database::singleton();
// Check if relation signature exists: $relationName[$srcConcept*$tgtConcept]
$relation = Relation::isCombination($relationName, $srcConcept, $tgtConcept);
$srcAtoms = explode('_AND', $srcAtom);
$tgtAtoms = explode('_AND', $tgtAtom);
if (count($srcAtoms) > 1) {
throw new Exception('DelPair function call has more than one src atom', 501);
}
// 501: Not implemented
if (count($tgtAtoms) > 1) {
throw new Exception('DelPair function call has more than one tgt atom', 501);
}
// 501: Not implemented
foreach ($srcAtoms as $a) {
foreach ($tgtAtoms as $b) {
$database->editDelete($relation, false, $a, $srcConcept, $b, $tgtConcept, 'ExecEngine');
}
}
return 'Tuple (' . $srcAtom . ' - ' . $tgtAtom . ') deleted from ' . $relationName . '[' . $srcConcept . '*' . $tgtConcept . ']';
} catch (Exception $e) {
Notifications::addError('DelPair: ' . $e->getMessage());
}
}
示例2: editDelete
public function editDelete($rel, $isFlipped, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source = 'User')
{
Notifications::addLog("editDelete({$rel}, " . var_export($isFlipped, true) . ", {$stableAtom}, {$stableConcept}, {$modifiedAtom}, {$modifiedConcept})", 'DATABASE');
try {
// This function is under control of transaction check!
if (!isset($this->transaction)) {
$this->startTransaction();
}
$stableAtom = $this->typeConversion($stableAtom, $stableConcept);
$modifiedAtom = $this->typeConversion($modifiedAtom, $modifiedConcept);
// Check if $rel, $srcConcept, $tgtConcept is a combination
$srcConcept = $isFlipped ? $modifiedConcept : $stableConcept;
$tgtConcept = $isFlipped ? $stableConcept : $modifiedConcept;
$fullRelationSignature = Relation::isCombination($rel, $srcConcept, $tgtConcept);
// Get table properties
$table = Relation::getTable($fullRelationSignature);
$srcCol = Relation::getSrcCol($fullRelationSignature);
$tgtCol = Relation::getTgtCol($fullRelationSignature);
// Determine which Col must be editited and which must be used in the WHERE statement
$stableCol = $isFlipped ? $tgtCol : $srcCol;
$modifiedCol = $isFlipped ? $srcCol : $tgtCol;
// Escape atoms for use in query
$modifiedAtomEsc = $this->escape($modifiedAtom);
$stableAtomEsc = $this->escape($stableAtom);
// Get database table information
$tableStableColumnInfo = Relation::getTableColumnInfo($table, $stableCol);
$tableModifiedColumnInfo = Relation::getTableColumnInfo($table, $modifiedCol);
// If the modifiedCol can be set to null, we do an update
if ($tableModifiedColumnInfo['null']) {
$this->Exe("UPDATE `{$table}` SET `{$modifiedCol}` = NULL WHERE `{$stableCol}` = '{$stableAtomEsc}' AND `{$modifiedCol}` = '{$modifiedAtomEsc}'");
// Elseif the stableCol can be set to null, we do an update
} elseif ($tableStableColumnInfo['null']) {
$this->Exe("UPDATE `{$table}` SET `{$stableCol}` = NULL WHERE `{$stableCol}` = '{$stableAtomEsc}' AND `{$modifiedCol}` = '{$modifiedAtomEsc}'");
// Otherwise, binary table, so perform a delete
} else {
$this->Exe("DELETE FROM `{$table}` WHERE `{$stableCol}` = '{$stableAtomEsc}' AND `{$modifiedCol}` = '{$modifiedAtomEsc}'");
}
$this->addAffectedRelations($fullRelationSignature);
// add relation to affected relations. Needed for conjunct evaluation.
Hooks::callHooks('postDatabaseDelete', get_defined_vars());
} catch (Exception $e) {
// Catch exception and continue script
Notifications::addError($e->getMessage());
}
}
示例3: OverwritePopulation
function OverwritePopulation($rArray, $relationName, $concept)
{
try {
$database = Database::singleton();
$fullRelationSignature = Relation::isCombination($relationName, $concept, $concept);
$table = Relation::getTable($fullRelationSignature);
$srcCol = Relation::getSrcCol($fullRelationSignature);
$tgtCol = Relation::getTgtCol($fullRelationSignature);
$query = "TRUNCATE TABLE {$table}";
$database->Exe($query);
foreach ($rArray as $src => $tgtArray) {
foreach ($tgtArray as $tgt => $bool) {
if ($bool) {
$query = "INSERT INTO {$table} (`{$srcCol}`, `{$tgtCol}`) VALUES ('{$src}','{$tgt}')";
$database->Exe($query);
}
}
}
} catch (Exception $e) {
throw new Exception('OverwritePopulation: ' . $e->getMessage(), 500);
}
}