Note that there are some explanatory texts on larger screens.

plurals
  1. POOverriding Propel 1.6 constructor throws warnings when populating objects
    primarykey
    data
    text
    <p>I have the following model where I'm overriding the constructor of the <code>base class</code>:</p> <pre><code>class Tasks extends BaseTasks { public function __construct($currentUser, $taskId, $startTime) { parent::__construct(); //........ //set all parameters to their respective fields //........ } </code></pre> <p>When I manually create a task using: <code>$task= new Task('test_user',1,'10:15');</code> everything works fine.</p> <p>The problem is when I fetch all tasks from the database:</p> <pre><code> $tasks = TasksQuery::create()-&gt;find(); </code></pre> <p>I get the errors: </p> <pre><code>Warning: Missing argument 1 for Tasks::__construct(), called in... Warning: Missing argument 2 for Tasks::__construct(), called in... Warning: Missing argument 3 for Tasks::__construct(), called in... </code></pre> <p>The stack trace shows that Propel in calling the constructor then populateObject to return the tasks objects with data:</p> <pre><code>Call Stack: //...other function calls 0.1254 19326792 14. call_user_func(array (0 =&gt; 'TasksPeer', 1 =&gt; 'populateObject'), array (0 =&gt; '98', 1 =&gt; '2013-07-16 15:25:00', 2 =&gt; 'daily',...other params...) /library/propel1_6/formatter/PropelObjectFormatter.php:87 0.1254 19326824 15. BaseTasksPeer::populateObject($row = array (0 =&gt; '98', 1 =&gt; '2013-07-16 15:25:00', ...other params...) /library/propel1_6/formatter/PropelObjectFormatter.php:87 0.1254 19330456 16. Tasks-&gt;__construct($currentUser = ???, $taskId = ???, $startTime = ???) /models/om/BaseTasksPeer.php:485 </code></pre> <p>Now if I decided to use value object in the constructor instead of the primitive data types like:</p> <p>class Tasks extends BaseTasks { </p> <pre><code> public function __construct(User $currentUser, $taskId, StartTime $startTime) { parent::__construct(); //........ //set all parameters to their respective fields //........ } </code></pre> <p>The call to the constructor will fail with a fatal error!! Is there a way to solve this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload