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

时间:2011-07-22 15:11:58

标签: php symfony1 symfony-1.4 propel

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

该模型已生成方法“doSelectJoinMeetingItems”,该方法应将我的会议操作表加入我的会议项目表(请参阅下面生成的代码的引用)。

但是,使用此方法时,我收到以下错误:Warning: Missing argument 1 for sfComponent::__construct(), - 请参见下文。

有谁知道为什么会这样?我所做的只是使用Symfonys自己生成的方法尝试通过我的ORM获取数据给我!

感谢您的时间,

我的代码:

Inside 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);

来自sfComponnent.class.php的第36行

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

1 个答案:

答案 0 :(得分:1)

我找到了问题,在Symfony 1.4中你不能有一个以动作结尾的类,例如UserActions或GroupActions(希望在某处正确记录)。

我希望这更好地记录,错误更有用!

  

一个类名(在schema.yml中),例如以'%Actions'结尾   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

上的帖子