コード例 #1
0
ファイル: StorageReflection.php プロジェクト: nextras/orm
 protected function getDefaultMappings()
 {
     $mappings = [self::TO_STORAGE => [], self::TO_ENTITY => []];
     $columns = array_keys($this->platform->getForeignKeys($this->storageName));
     foreach ($columns as $storageKey) {
         $entityKey = $this->formatEntityForeignKey($storageKey);
         $mappings[self::TO_ENTITY][$storageKey] = [$entityKey, null];
         $mappings[self::TO_STORAGE][$entityKey] = [$storageKey, null];
     }
     $storagePrimaryKey = $this->getStoragePrimaryKey();
     if (count($this->entityPrimaryKey) !== count($storagePrimaryKey)) {
         throw new InvalidStateException('Mismatch count of entity primary key (' . implode(', ', $this->entityPrimaryKey) . ') with storage primary key (' . implode(', ', $storagePrimaryKey) . ').');
     }
     if (count($storagePrimaryKey) === 1) {
         $entityKey = $this->entityPrimaryKey[0];
         $storageKey = $storagePrimaryKey[0];
         $mappings[self::TO_ENTITY][$storageKey] = [$entityKey, null];
         $mappings[self::TO_STORAGE][$entityKey] = [$storageKey, null];
     }
     return $mappings;
 }
コード例 #2
0
ファイル: CachedPlatform.php プロジェクト: nextras/dbal
 public function getForeignKeys($table)
 {
     return $this->cache->load('foreign_keys.' . $table, function () use($table) {
         return $this->platform->getForeignKeys($table);
     });
 }