Hi I am using a PHP Symfony project and am trying to use the generated model peer class to make a query.
The model has generated the method “doSelectJoinMeetingItems” which is supposed to join my Meeting Actions Table to my Meeting Items table (see a quote of the generated code below).
However, when using this method I get the following error: Warning: Missing argument 1 for sfComponent::__construct(), – see in full below.
Does anyone know why this is happening? All I am doing is using Symfonys own generated methods to try and get data through my ORM to me!
Thanks for your time,
My code:
Inside MeetingMeetingsPeer
return self::doSelectJoinMeetingItems(new Criteria());
The auto generated 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;
}
The Error in Full
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
The lines 582 to 586 are as follows:
582 $cls = MeetingActionsPeer::getOMClass(false);
583
584 $obj1 = new $cls();
585 $obj1->hydrate($row);
586 MeetingActionsPeer::addInstanceToPool($obj1, $key1);
Line 36 from sfComponnent.class.php
36 public function __construct($context, $moduleName, $actionName)
37 {
38 $this->initialize($context, $moduleName, $actionName);
39 }
I have located the problem, in Symfony 1.4 you cannot have a class that ends in actions for example UserActions or GroupActions (wish this was properly documented somewhere).
I wish this was better documented and the error was more useful!
See post at http://trac.symfony-project.org/wiki/ReservedWords