【问题标题】:php doctrine behavior helpphp教义行为帮助
【发布时间】:2009-11-09 21:38:58
【问题描述】:

我正在浏览教义教程,但遇到了一个问题。自动加载功能是否不适用于行为?

This 是我一直在关注的教程。它应该在生成时自动创建提到的表之间的关系,但是我只是收到一条错误消息,指出表中不存在相应的外部 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 架构中,则行为完全符合预期。

谁能帮帮我?

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

【问题讨论】:

    标签: php doctrine


    【解决方案1】:

    我认为示例中有错字:

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

    应该是

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-22
      • 2011-09-25
      • 1970-01-01
      • 1970-01-01
      • 2010-12-25
      • 2011-03-02
      • 2011-05-05
      • 2013-03-31
      相关资源
      最近更新 更多