[FX.php List] PHP Array question

David Ness dness at bondedbuilders.com
Fri Sep 15 09:22:21 MDT 2006


I need a little help to understand arrays.

Here's the scenario:

I'm reading record data from a csv file to populate a FileMaker table.
That all works fine. For each record read, I want to see if a field
value in the record read already exists in my target database for that
customer, in which case I'm skipping that record and moving onto the
next.

My current solution performs a fx.PHP query against the FileMaker table
for each csv record as it's read. This works, but results in hundreds of
fx.PHP queries, once for each record in the csv file.

So instead, I though I could read in all of the existing FM field values
into an array with a single fx.PHP query, then use that PHP array in the
comparison, using the php in_array statement. But I'm a little fuzzy on
this, as you'll see from the following code fragment:

// Read in all values contained in the referenceNumber field from FM
// Layout 'referenceNumberLayout' contains 2 fields:
//	'customer_number' & 'referenceNumber'
$Query = new FX($serverIP,$webCompanionPort);
$Query->SetDBData($databasename,'referenceNumberLayout', 'all');
$Query->SetDBPassword($password,$username);
$Query->AddDBParam('customer_number', $customerNumber, "eq" );
$referenceNumber_array = $Query->FMFind();


while (($importdata = fgetcsv($handle, 0, ",")) != FALSE) {
	// Check to see if Builder Ref#/Job# is unique for this builder.
	// This is the mechanism for handling (excluding) duplicate
submissions.
	// $importdata[0] contains the reference number

	if( in_array( $importdata[0],
$referenceNumber_array['referenceNumber'] )) {
		$validationMsg = 'Skipped';
	}
}
					
I'm sure my problem is in the 'if( in_array(...' statement, but I'm not
clear how I reference the array of reference numbers.

Help is greatly appreciated.


--
David Ness,
Database Systems Programmer
 
Bonded Builders Warranty Group
1500 Kings Highway
Port Charlotte, FL 33980
800.749.0381 x3123 (National Toll Free)
941.255.3274 x3123 (Local)
 


More information about the FX.php_List mailing list