Jump to content

Retrieving field data after ADD


Gary Hoffman
 Share

This topic is 4372 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I'm familiar with FX and now I'm trying the PHP API. In FX, the result array from an ADD operation contains the data that was just added to the database. However, when I examine the result of an ADD operation using the PHP API, I don't find the record contents. Am I missing something? Is it really there? Maybe I have to Find the last record to get the contents.

Link to comment
Share on other sites

The data is all there, but it is in an object not a standard data array. If you look at the api documentation for Result and Record objects, and the methods you can use on each, you should be able to get a better understanding of how it works.

Here is a little example of how you would get field data from a found set...

$result = $findCommand->execute();

$records = $result->getRecords();



// access data from all records

foreach( $records as $record ) {

    ECHO $record->getField('fieldName');

}



// access data from only the first record

$record = $records[0];

ECHO $record->getField('fieldName');

Link to comment
Share on other sites

  • 1 month later...

To clarify a little further, when you execute the add command a FileMaker result object is returned containing the record that was just added. You access the record the same way you would if you were dealing with a result generated by a find command.

$result = $addCommand->execute();

if( !FileMaker::isError($result) ){

 	$record = $result->getFirstRecord();

 	echo $record->getField("fieldName");

}

Link to comment
Share on other sites

This topic is 4372 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.