[FX.php List] Showing last related record - sort in FM or just
PHP?
Dale Bengston
dbengston at preservationstudio.com
Mon Oct 16 19:15:32 MDT 2006
Hi Joel,
Well, if your relationship is sorted last-to-first, it will be
element 0 of the related field array, so you can just reference that
explicitly:
echo $value['relationship::myField'][0];
If your relationship is not sorted, you can easily find the last
element with the PHP end function:
echo end($value['relationship::myField']);
I like to use PHP to do as much of the work as possible. No unstored
calc fields necessary here.
Dale
On Oct 16, 2006, at 7:31 PM, Joel Shapiro wrote:
> Great. Thanks Steve!
>
> I'll plan on returning all related records (by default) and then
> sorting in php to display only the one I want.
>
> Best,
> -Joel
>
>
> On Oct 16, 2006, at 5:16 PM, Steve Winter wrote:
>
>> Hi Joel,
>>
>>>> my best advice, sort in fmp in the relationship definition.
>>>
>>> but if the WPE will spit back *all* related records regardless,
>>> wouldn't it be faster to have FM return all the data unsorted and do
>>> the sorting within PHP?
>>
>> Probably... if you were actually going to do some form of sort,
>> then it
>> would most likely be quicker to do it in php. If it was a sort order
>> applied to the relationship I don't think it will make any
>> difference...
>>
>>>> if you want to get really trick and you are sure you only ever
>>>> need one (most recent) record you can make a calc field that just
>>>> returns the last record. that way PHP doesn't have to transform a
>>>> bunch of XML data that you'll never use.
>>>
>>> I've heard it's optimal to not have calc fields on the web layout if
>>> possible (for speed), but do you think that in this case it could
>>> still be faster than returning all related records?
>>
>> Personally I think this would be the slowest option... unstored
>> calculation fields are going to be slower for the wpe to process
>> than all
>> of the related records (IMHO)
>>
>> Cheers
>> Steve
>>
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
More information about the FX.php_List
mailing list