0

我正在阅读教义教程并且遇到了一个问题。自动加载功能是否不适用于行为?

是我一直在关注的教程。它应该在生成时自动创建提到的表之间的关系,但是我只是收到一条错误消息,指出表中不存在相应的外部 id 列。

这是应该运行的特定代码位,但似乎没有。

public function setTableDefinition()
{
    foreach ($this->_options['relations'] as $relation) {
        $columnName = Doctrine_Inflector::tableize($relation) . '_id';
        if (!$this->_table->hasColumn($columnName)) {
            $this->hasColumn($columnName, 'integer');
        }
    }
}

如果我手动将列添加到我的 yaml 架构中,则行为完全符合预期。

谁能帮我吗?

任何建议表示赞赏,谢谢。

4

1 回答 1

1

我认为示例中有一个错字:

if (!$this->_table->hasColumn($columnName)) {
    $this->hasColumn($columnName, 'integer');
}

应该

if (!$this->_table->hasColumn($columnName)) {
    $this->setColumn($columnName, 'integer');
}
于 2009-11-19T00:24:46.053 回答