Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The output you have shown looks as if the <code>toArray</code> function has been used on the Propel objects and then the <a href="http://php.net/json_encode" rel="nofollow"><code>json_encode</code></a> function. This should work if you define foreign keys mutually in Propel's <code>schema.xml</code>.</p> <p>Since project tasks, account tasks and bug tracker tasks all have something in common, they all are tasks :), I would organize them as sub classes of a more general task entity.</p> <p>You will end up with a collection of tables like this:</p> <p>Table <strong>"task"</strong></p> <pre><code>id | name ------------------------ 1 | Start a project 2 | Create a contract 3 | Fix a bug 4 | Start another project 5 | Fix another bug --------------------------------------- </code></pre> <p>Table <strong>"bugtrack_task"</strong></p> <pre><code>id | id_task --------------- 1 | 3 2 | 5 --------------------------------------- </code></pre> <p>Table <strong>"project_task"</strong></p> <pre><code>id | id_task --------------- 1 | 1 2 | 4 --------------------------------------- </code></pre> <p>Table <strong>"account_task"</strong></p> <pre><code>id | id_task --------------- 1 | 2 </code></pre> <p>In the end, you would define a view in the <code>schema.xml</code>. This could look something like this:</p> <pre><code>&lt;table name="view_task" phpName="ViewTask" skipSql="true" readOnly="true" description="All my tasks together for display"&gt;...&lt;/table&gt; </code></pre> <p>Note that the <code>skipSql</code> attribute has been set to <code>true</code>. This will skip this view table when generating the SQL code. Propel will generate the classes for you but won't touch your database. You can now manually define the view yourself putting into it whatever you desire.</p> <p>Of course you'd have to put some effort into creating this view but it pays off as you will be able to use the Propel classes like so for instance:</p> <pre><code>$tasks = ViewTask::create()-&gt;find(); $result = array(); foreach($tasks as $task) { $result[] = $task-&gt;toArray(); } return json_encode($result); </code></pre> <p>This isn't a complete answer but I hope you see the idea! Good luck :-)</p>
 

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