2

推进版本:1.6.7

PropelException当我尝试在我的应用程序中运行以下代码时,我得到了一个(此代码在AdminController控制器操作下调用的类中运行)。有问题的代码尝试创建一个新ContentPage对象,该对象是该类的子Page类并使用 Propel 的具体表继承

$page = new ContentPage;
$page->fromData($_POST); // Modified, more secure version of fromArray();
$page->save();

除了:

调用未定义的方法:getPage

getParentOrCreate使用在 Propel 生成的类中的 Propel生成的方法中调用的方法BaseContentPage

//this prevent issue with deep copy & save parent object
if (null === ($parent = $this->getPage($con))) {

我的schema.xml文件如下所示:

<!-- Page -->
<table name="page" phpName="Page">
  (columns)
</table>

<!-- ContentPage : Page -->
<table name="contentpage" phpName="ContentPage">
  <behavior name="concrete_inheritance">
    <parameter name="extends" value="page" />
  </behavior>
</table>

我的schema.xml代码有问题吗,还是你们已经看到并解决了这个错误?

4

1 回答 1

1

您的架构可能没问题,但我今天偶然发现了同样的错误。我找到了一种解决方法并在 github 上创建了一个问题。简而言之,就是注释掉concrete_inheritance行为源代码中的三行代码,重新生成模型,如果还没做,更新数据库。

https://github.com/propelorm/PropelBundle/issues/206

于 2013-01-25T17:35:51.650 回答