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