当前位置: 首页>>代码示例>>PHP>>正文


PHP Relation::getSrcCol方法代码示例

本文整理汇总了PHP中Relation::getSrcCol方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::getSrcCol方法的具体用法?PHP Relation::getSrcCol怎么用?PHP Relation::getSrcCol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Relation的用法示例。


在下文中一共展示了Relation::getSrcCol方法的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());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:45,代码来源:Database.php

示例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);
    }
}
开发者ID:4ZP6Capstone2015,项目名称:Capstone,代码行数:22,代码来源:warshall.php


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