[FX.php List] Portal vs 2nd query [Was: Related Records]

Derrick Fogle derrick at fogles.net
Tue Mar 21 13:45:10 MST 2006


On Mar 21, 2006, at 2:09 PM, Joel Shapiro wrote:

> On a layout based on the Business table, I have a portal to the  
> ContactPhone records.  When the portal is sorted by ContactID, the  
> rows would look like:
> C12    555-1234    Joel
> C12    555-1235    Joel
> C14    444-2222    Derrick
>
> You're saying that I could pull in these 3 related records via code  
> like your earlier sample:
> and then within the PHP break these 3 into their 2 respective  
> contacts -- kind of like a subsummary in FMP.
>
> Is that right?

Correct.

The logical execution of  the PHP is similar to what you'd do in an  
FMP script, but of course completely different <grin>. Now, you need  
to realize that I'm not a very good PHP coder, but I can hack away  
until I get what I want. I'm sure someone else with better PHP skills  
could supply more concise code for the if/else part, but this should  
at least demonstrate the concept.

So you've got your FM layout all set up, with a portal to  
ContactPhone that shows data from both Contact and ContactPhone. This  
would be the snippet of code that might approach what you want:

$prow = 0;
$contact = NULL;
while($value['ContactPhone::Record_ID'][$prow]) {
	if($value['Contact::Name'][$prow]!=$contact) {
		$contact = $value['Contact::Name'][$prow];
		echo $contact;
	} else {
		echo "&nbsp;&nbsp;&nbsp;
	}
	echo $value['ContactPhone::Number'][$prow];
	echo "<br />";
	$prow++;
}

Of course I would normally have this formatted as table data, but to  
heck with that just for the example. This does the same thing that an  
FMP sub-summary does - if the value of the Contact::Name is not the  
same as the previous record, it displays it, otherwise it does not.

Just remember that doing something like this is almost completely  
unique to Filemaker, because it is so horribly slow as a back-end DB  
for anything but an FM client. Consensus is that depending on your  
iron, you are only going to get 1-2 transactions per second, maybe up  
to 4 if you've got really hot iron.

Derrick Fogle
derrick at fogles.net





More information about the FX.php_List mailing list