Page 1 of 1

table list only most recent for each related record

PostPosted: Tue Aug 07, 2012 4:37 pm
by cookie720
I have a table called status, which is a lookup of whats going on with a matter.
I have set my database up so that it keeps the previous status and when you create a new status, it gets the old data as default. This allows a sort of "history" of whats going on with a particular matter.
In my main view, I am listing only the most recent status record by
Code: Select all
function __sql__(){
return "SELECT * FROM `status` ORDER BY `StatusID` DESC";
}

then using
Code: Select all
$related_records =& $record->getRelatedRecordObjects('status');
      $content = '<b>To Do: </b>'.$related_records[0]->htmlValue('ToDo')
      .'<br><br><b>Awaiting: </b>'.$related_records[0]->htmlValue('Awaiting');
to list only those two fields from the first ("most recent") record.

The problem im facing is obviously when i click onto this status tab (up the top) it lists ALL statuses via that SQL query, So I get a table full of unwanted data. I only ened the most recent for each related record (matter).

doing LIMIT 1 just breaks everything...

Thanks in advance for all the smart people that can help me :mrgreen:

Re: table list only most recent for each related record

PostPosted: Tue Aug 07, 2012 5:25 pm
by shannah
What does the relationship definition for the status relationship look like?

Re: table list only most recent for each related record

PostPosted: Mon Aug 13, 2012 4:50 am
by cookie720
my "matters" table is the table everything links to, all my other tables have the same relationship.ini, as follows for the status relationship.ini:
Code: Select all
[matters]
section:visible=0
matters.MatterID = "$MatterID"


and my status definition in the matters relationship.ini:
Code: Select all
[status]
section:visible=0
status.MatterID = "$MatterID"

Re: table list only most recent for each related record

PostPosted: Wed Aug 15, 2012 4:53 pm
by cookie720
i still cant get it working my i know a bit about sql but with the dataface records stuff im kind of clueless , anyone? :(