我正在尝试使用 Propel 2 从 MSSQL 数据库反向生成架构。我已经像往常一样设置了 YAML 配置文件:
dbname:
adapter: mssql
classname: Propel\Runtime\Connection\ConnectionWrapper
dsn: "dblib:host=123.456.789.012;dbname=dbname"
user: username
password: password
attributes:
当我运行命令 propel reverse 'dbname'
时,我收到错误:
[Propel\Generator\Exception\EngineException]
Column "" declared twice in table "Status"
这显然是抛出在这里: 奥 git _a @r499
为什么 Propel 尝试添加“空”列?当我查看数据库表Status
的设计时,我的SQL Server Management Studio根本不显示空列,它只显示它包含的两列(uid
和名称
)。
编辑: 于是我深入研究了Propel的代码,发现这里似乎出了问题: https://github.com/propelorm/Propel2/blob/master/src/Propel/Generator/Model/Table.php#L499
protected function addColumns(Table $table)
{
$dataFetcher = $this->dbh->query("sp_columns '" . $table->getName() . "'");
foreach ($dataFetcher as $row) {
$name = $this->cleanDelimitedIdentifiers($row['COLUMN_NAME']);
$table->getName()
正确返回正确的表名称。当我打印 dataFetcher 时,它是一个 PDO 对象。然而:
$row
给出以下数组:
Array(
[0] => My DBname
[1] => My DBprefix
[2] => Status
[3] => uid
[4] => 4
[5] => int identity
etc. no string indices hence COLUMN_NAME is empty.
最佳答案
(代表 OP 发布):
这是 Propel MSSQL 模式解析器中的一个错误:https://github.com/propelorm/Propel2/issues/863 .
关于sql-server - 列 ""在 Propel 2 的表 "status"中声明了两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27985791/