Symfony PHP使用Join时缺少参数错误


Symfony PHP Missing Argument Error when using Join

嗨,我正在使用PHP Symfony项目,我试图使用生成的模型对等类进行查询。

模型已经生成了方法"doSelectJoinMeetingItems",它应该加入我的会议动作表到我的会议项表(见下面生成的代码的引用)。

然而,当使用这种方法时,我得到以下错误:Warning: Missing argument 1 for sfComponent::__construct(), -见下面的全部内容。

有人知道为什么会这样吗?我所做的就是使用Symfonys自己生成的方法来尝试通过我的ORM获得数据!

谢谢你的时间,

我的代码:

在MeetingMeetingsPeer

return self::doSelectJoinMeetingItems(new Criteria());

自动生成的baseMeetingActionsPeer

public static function doSelectJoinMeetingItems(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
{
    $criteria = clone $criteria;
    // Set the correct dbName if it has not been overridden
    if ($criteria->getDbName() == Propel::getDefaultDB()) {
        $criteria->setDbName(self::DATABASE_NAME);
    }
    MeetingActionsPeer::addSelectColumns($criteria);
    $startcol = (MeetingActionsPeer::NUM_COLUMNS - MeetingActionsPeer::NUM_LAZY_LOAD_COLUMNS);
    MeetingItemsPeer::addSelectColumns($criteria);
    $criteria->addJoin(MeetingActionsPeer::ITEM_ID, MeetingItemsPeer::ID, $join_behavior);
    // symfony_behaviors behavior
    foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)
    {
      call_user_func($sf_hook, 'BaseMeetingActionsPeer', $criteria, $con);
    }
    $stmt = BasePeer::doSelect($criteria, $con);
    $results = array();
    while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
        $key1 = MeetingActionsPeer::getPrimaryKeyHashFromRow($row, 0);
        if (null !== ($obj1 = MeetingActionsPeer::getInstanceFromPool($key1))) {
            // We no longer rehydrate the object, since this can cause data loss.
            // See http://propel.phpdb.org/trac/ticket/509
            // $obj1->hydrate($row, 0, true); // rehydrate
        } else {
            $cls = MeetingActionsPeer::getOMClass(false);
            $obj1 = new $cls();
            $obj1->hydrate($row);
            MeetingActionsPeer::addInstanceToPool($obj1, $key1);
        } // if $obj1 already loaded
        $key2 = MeetingItemsPeer::getPrimaryKeyHashFromRow($row, $startcol);
        if ($key2 !== null) {
            $obj2 = MeetingItemsPeer::getInstanceFromPool($key2);
            if (!$obj2) {
                $cls = MeetingItemsPeer::getOMClass(false);
                $obj2 = new $cls();
                $obj2->hydrate($row, $startcol);
                MeetingItemsPeer::addInstanceToPool($obj2, $key2);
            } // if obj2 already loaded
            // Add the $obj1 (MeetingActions) to $obj2 (MeetingItems)
            $obj2->addMeetingActions($obj1);
        } // if joined row was not null
        $results[] = $obj1;
    }
    $stmt->closeCursor();
    return $results;
}

Warning: Missing argument 1 for sfComponent::__construct(), called in /var/www/html/dev/meeting/lib/model/om/BaseMeetingActionsPeer.php on line 584 and defined in /var/www/html/dev/meeting/lib/vendor/symfony/lib/action/sfComponent.class.php on line 36
Warning: Missing argument 2 for sfComponent::__construct(), called in /var/www/html/dev/meeting/lib/model/om/BaseMeetingActionsPeer.php on line 584 and defined in /var/www/html/dev/meeting/lib/vendor/symfony/lib/action/sfComponent.class.php on line 36
Warning: Missing argument 3 for sfComponent::__construct(), called in /var/www/html/dev/meeting/lib/model/om/BaseMeetingActionsPeer.php on line 584 and defined in /var/www/html/dev/meeting/lib/vendor/symfony/lib/action/sfComponent.class.php on line 36
Notice: Undefined variable: context in /var/www/html/dev/meeting/lib/vendor/symfony/lib/action/sfComponent.class.php on line 38
Fatal error: Call to a member function getEventDispatcher() on a non-object in /var/www/html/dev/meeting/lib/vendor/symfony/lib/action/sfComponent.class.php on line 55

第582至586行如下:

582    $cls = MeetingActionsPeer::getOMClass(false);
583    
584    $obj1 = new $cls();
585    $obj1->hydrate($row);
586    MeetingActionsPeer::addInstanceToPool($obj1, $key1);

来自sfcomponent .class.php的第36行

36    public function __construct($context, $moduleName, $actionName)
37      {
38        $this->initialize($context, $moduleName, $actionName);
39      }

我已经找到了问题,在Symfony 1.4中,您不能有一个以actions结束的类,例如UserActions或GroupActions(希望这在某个地方得到了适当的记录)。

我希望这是更好的文档和错误更有用!

例如,

以'%Actions'结尾的类名(在schema.yml中)UserActions吗?(symfony 1.4.10)。添加时抛出错误与之相关的对象形式的额外字段(带验证)这种"*行动"。

wrapped: Warning: Missing argument 2 for sfComponent::__construct(), called in 
/Users/Shared/Library/symfony-1.4.10/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Table.php 
on line 301 and defined in /Users/Shared/Library/symfony-1.4.10/lib/action/sfComponent.class.php on line 36 
Warning: Missing argument 3 for sfComponent::__construct(), called in 
/Users/Shared/Library/symfony-1.4.10/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Table.php 
on line 301 and defined in /Users/Shared/Library/symfony-1.4.10/lib/action/sfComponent.class.php on line 36]

参见http://trac.symfony-project.org/wiki/ReservedWords