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


PHP TActiveRecord::getRecordGateway方法代码示例

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


在下文中一共展示了TActiveRecord::getRecordGateway方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: findForeignKeys

 /**
  * Returns foreign keys in $fromRecord with source column names as key
  * and foreign column names in the corresponding $matchesRecord as value.
  * The method returns the first matching foreign key between these 2 records.
  * @param TActiveRecord $fromRecord
  * @param TActiveRecord $matchesRecord
  * @return array foreign keys with source column names as key and foreign column names as value.
  */
 protected function findForeignKeys($from, $matchesRecord, $loose = false)
 {
     $gateway = $matchesRecord->getRecordGateway();
     $recordTableInfo = $gateway->getRecordTableInfo($matchesRecord);
     $matchingTableName = strtolower($recordTableInfo->getTableName());
     $matchingFullTableName = strtolower($recordTableInfo->getTableFullName());
     $tableInfo = $from;
     if ($from instanceof TActiveRecord) {
         $tableInfo = $gateway->getRecordTableInfo($from);
     }
     //find first non-empty FK
     foreach ($tableInfo->getForeignKeys() as $fkeys) {
         $fkTable = strtolower($fkeys['table']);
         if ($fkTable === $matchingTableName || $fkTable === $matchingFullTableName) {
             $hasFkField = !$loose && $this->getContext()->hasFkField();
             $key = $hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys'];
             if (!empty($key)) {
                 return $key;
             }
         }
     }
     //none found
     $matching = $gateway->getRecordTableInfo($matchesRecord)->getTableFullName();
     throw new TActiveRecordException('ar_relations_missing_fk', $tableInfo->getTableFullName(), $matching);
 }
开发者ID:Nurudeen,项目名称:prado,代码行数:33,代码来源:TActiveRecordRelation.php


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