php - Overriding Propel 1.6 constructor throws warnings when populating objects -
i have following model i'm overriding constructor of base class:
class tasks extends basetasks { public function __construct($currentuser, $taskid, $starttime) { parent::__construct(); //........ //set parameters respective fields //........ } when manually create task using: $task= new task('test_user',1,'10:15'); works fine.
the problem when fetch tasks database:
$tasks = tasksquery::create()->find(); i errors:
warning: missing argument 1 tasks::__construct(), called in... warning: missing argument 2 tasks::__construct(), called in... warning: missing argument 3 tasks::__construct(), called in... the stack trace shows propel in calling constructor populateobject return tasks objects data:
call stack: //...other function calls 0.1254 19326792 14. call_user_func(array (0 => 'taskspeer', 1 => 'populateobject'), array (0 => '98', 1 => '2013-07-16 15:25:00', 2 => 'daily',...other params...) /library/propel1_6/formatter/propelobjectformatter.php:87 0.1254 19326824 15. basetaskspeer::populateobject($row = array (0 => '98', 1 => '2013-07-16 15:25:00', ...other params...) /library/propel1_6/formatter/propelobjectformatter.php:87 0.1254 19330456 16. tasks->__construct($currentuser = ???, $taskid = ???, $starttime = ???) /models/om/basetaskspeer.php:485 now if decided use value object in constructor instead of primitive data types like:
class tasks extends basetasks {
public function __construct(user $currentuser, $taskid, starttime $starttime) { parent::__construct(); //........ //set parameters respective fields //........ } the call constructor fail fatal error!! there way solve this?
the base class calls constructor, without arguments. in order avoid warning, make arguments optional
public function __construct($currentuser = null, $taskid = null, $starttime = null) { ... } instead of null can, of course, use appropriate values application demands.
Comments
Post a Comment