table list only most recent for each related record

A place for users and developers of the Xataface to discuss and receive support.

table list only most recent for each related record

Postby cookie720 » Tue Aug 07, 2012 4:37 pm

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:
cookie720
 
Posts: 69
Joined: Mon Jun 04, 2012 9:22 pm

Re: table list only most recent for each related record

Postby shannah » Tue Aug 07, 2012 5:25 pm

What does the relationship definition for the status relationship look like?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: table list only most recent for each related record

Postby cookie720 » Mon Aug 13, 2012 4:50 am

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"
cookie720
 
Posts: 69
Joined: Mon Jun 04, 2012 9:22 pm

Re: table list only most recent for each related record

Postby cookie720 » Wed Aug 15, 2012 4:53 pm

i still cant get it working my i know a bit about sql but with the dataface records stuff im kind of clueless , anyone? :(
cookie720
 
Posts: 69
Joined: Mon Jun 04, 2012 9:22 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 14 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved