You could use the function __sql__() in your main table delagate class to replace the current sql request by the one you want.
However, this will transform the main table for all the application, which is not often the best way to do it.
You could also make an action (
http://xataface.com/documentation/tutorial/getting_started/dataface_actions).
in you case your actions/myaction.php should look like :
- Code: Select all
<?php
class actions_myaction {
function handle(&$params){
$res = mysql_query("select table1.*, table2.field FROM table1 LEFT JOIN table2 ON (table1.fieldID=table2.relatedfieldID)")or die("Error: ".mysql_error());
while ($row = mysql_fetch_assoc($res)) {
$items[] = $row;
}
df_display(array('tableau'=>$items), 'mytemplate.html');
}
?>
and the templates/mytemplate.html
- Code: Select all
{use_macro file="Dataface_Main_Template.html"}
{fill_slot name="main_section"}
<table id="relatedList" class="listing" >
<thead>
<tr>
<th>Field1title</th>
<th>Field2title</th>
<th>Field3title</th>
</tr>
</thead>
<tbody id="relatedList-body">
{foreach from=$tableau item=record}
<tr class="{cycle values='even,odd'}" >
<td> {$record.Field1}</td>
<td> {$record.Field2}</td>
<td> {$record.Field3}</td>
</tr>
{/foreach}
</tbody>
</table>
{/fill_slot}
{/use_macro}