コード例 #1
0
 public function getParentProperty($database, $tableName, $parentTable, $key)
 {
     /*UserClassInfo*/
     $userClassInfo = $this->m_model->GetClassInfo($this->m_dbNameToConnection[$database], $tableName);
     if ($userClassInfo != null) {
         /*UserRelationInfo*/
         $relationInfo = $userClassInfo->GetRelation($key, RelationType::Parent);
         if ($relationInfo != null) {
             return $relationInfo->Alias;
         }
     }
     return parent::getParentProperty($database, $tableName, $parentTable, $key);
 }
コード例 #2
0
 public function AddTableToDataModel($modelName, $schemaName, $tableName, $connectionId, $view)
 {
     $userSettings = self::GetSettings();
     $userDataModel = null;
     foreach ($userSettings->DataModels as $item) {
         if ($item->Name == $modelName) {
             $userDataModel = $item;
         }
     }
     if ($userDataModel == null) {
         throw new Exception("Data model with name '" . $modelName . "' not found");
     }
     $table = null;
     foreach ($userDataModel->Tables as $tableInfo) {
         if ($tableName == $tableInfo->Name && $connectionId == $tableInfo->DatabaseConnectionInfoId) {
             $table = $tableInfo;
         }
     }
     if ($table != null) {
         throw new Exception("Data model name '" . $modelName . "' already contains table '" . $tableName . "'");
     }
     $userDataModel->Tables[] = new UserTableInfo($schemaName, $tableName, $view, $connectionId);
     $userClassInfo = new UserClassInfo();
     $userClassInfo->DatabaseConnectionInfoId = $connectionId;
     $userClassInfo->TableName = $tableName;
     $userClassInfo->Name = DefaultNameMapper::getSafeName($tableName);
     $userDataModel->UserClasses[] = $userClassInfo;
     $tableMeta = self::GetTableMeta($connectionId, $schemaName, $tableName);
     foreach ($tableMeta->Columns as $columnInfo) {
         if (!DefaultNameMapper::isNameSafe($columnInfo->name)) {
             $userClassFieldInfo = new UserClassFieldInfo();
             $userClassFieldInfo->ColumnName = $columnInfo->name;
             $userClassFieldInfo->Name = DefaultNameMapper::getSafeName($columnInfo->name);
             $userClassInfo->Fields[] = $userClassFieldInfo;
         }
     }
     foreach ($tableMeta->Relations as $relationInfo) {
         if (!DefaultNameMapper::isNameSafe($relationInfo->RelatedTableName)) {
             $userRelationInfo = new UserRelationInfo();
             $userRelationInfo->Alias = "Related" . DefaultNameMapper::getSafeName($relationInfo->RelatedTableName);
             $userRelationInfo->ForeignKey = $relationInfo->ForeignKey;
             $userRelationInfo->Type = $relationInfo->Type;
             $userClassInfo->Relations[] = $userRelationInfo;
         }
     }
     $userSettings->Save(Paths::getWDMConfigPath());
     return $userClassInfo;
 }
コード例 #3
0
 public function getStoredProcedureName($name)
 {
     return DefaultNameMapper::getSafeName($name);
 }