[FX.php List] Updating repeating field with AddDBParam

Jack Kelly jlk4p at virginia.edu
Wed Aug 9 14:10:52 MDT 2006


Chris,

Thanks. The format you mentioned fieldname.repetitionnumber is  
correct way to update a FM 5/6 database.

I decided to include the complete snippet of code for my update in  
case it would be helpful for any other FM 5/6 users:

//Check to see if the update form has been submitted.
if (isset($_POST['edit']) and ($_POST['edit'] == "Update")) {
	if (isset($_POST['surrogateNo']) and ($_POST['surrogateNo'] != "")) {
		//Initiate database connection.
		$imageQuery = new FX($serverIP, $webCompanionPort, $dataSourceType);
		$imageQuery->SetDBData('SURROGAT.fp5','',1);	// result should be a  
single image record
		$imageQuery->SetDBUserPass($webUN,$webPW);
		
		//Update the desired fields.
		$imageQuery->AddDBParam('-recid',$_POST['recId']);
		//$imageQuery->AddDBParam('-modid',$_POST['modId']);
		$imageQuery->AddDBParam('Image Format',$_POST['imageFormat']);
		$imageQuery->AddDBParam('Identifier Type',$_POST['identifierType']);
		$imageQuery->AddDBParam('Identifier Number',$_POST 
['identifierNumber']);
		$i = 1;
		foreach ($_POST['viewTypes'] as $key => $value) {
			$imageQuery->AddDBParam("View Type.$i",$value);
			$i++;
		}
		$imageQuery->AddDBParam('View Description',$_POST['viewDescription']);
		$imageQuery->AddDBParam('View Date',$_POST['viewDate']);
		$imageQuery->AddDBParam('Image Notes',$_POST['imageNotes']);
		$imageQuery->AddDBParam('Approved',$_POST['approved']);
		$results = $imageQuery->FMEdit();
		//... additional code omitted
	}
}

On Aug 9, 2006, at 12:58 PM, Chris Hansen wrote:

> Jack,
>
> You're very close if I'm remembering correctly.  Of course, as with  
> any edit you need to specify the Record ID of the record that  
> you're modifying.  For the individual repetitions, however, you  
> need to specify which repetition to edit.  In FileMaker 5/6 this  
> was done by appending ".repNo" to each edit.  So, your loop would  
> look like this:
>
> $i = 1;
> foreach ($_POST['viewTypes'] as $key => $value) {
>     $imageQuery->AddDBParam('View Type.' . $i, $value);
>     $i++;
> }
>
> I'm not 100% sure of that, but I think it's right.  As I recall the  
> "FieldName(RelRecID).RepNo" syntax was new with FM7.  It does make  
> sense though, since the old way doesn't allow for repeating fields  
> within portals.  Let me know if this doesn't solve your problem and  
> I'll dig some more...
>
> Best,
>
> --Chris Hansen
>   FileMaker 7 Certified Developer
>   Creator of FX.php
>   "The best way from FileMaker to the Web."
>   www.iViking.org
>
>
> On Aug 9, 2006, at 7:05 AM, Jack Kelly wrote:
>
>> Folks,
>>
>> I've just started using the FX.php module and I'm having trouble  
>> finding info regarding how to properly qualify updating a  
>> repeating field when working with FM5/6.
>>
>> I tried just specifying the same parameter and repeating the value  
>> thinking it would understand that the same field indicated a  
>> repeating value which did not work:
>>
>> ...
>> foreach ($_POST['viewTypes'] as $key => $value) {
>>      $imageQuery->AddDBParam('View Type',$value);
>> }
>> ...
>>
>> And I tried using a format based on what the documentation said  
>> was needed when working with FM7 repeating/portal fields which  
>> does not work:
>>
>> ...
>> $i = 1;
>> foreach ($_POST['viewTypes'] as $key => $value) {
>> 	$imageQuery->AddDBParam("View Type($i)",$value);
>> 	$i++;
>> }
>> ...
>>
>> I tried the above with i=0 and i=1. And tried adding ".$recId"  
>> after the ($i). Neither worked.
>>
>> Does anyone know how I correctly specify repeating fields using  
>> the AddDBParam method with a FM5/6 database?
>>
>> Thanks in advance,
>> Jack_______________________________________________
>> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4206 bytes
Desc: not available
Url : http://www.iviking.org/pipermail/fx.php_list/attachments/20060809/09cc994d/smime-0001.bin


More information about the FX.php_List mailing list