Gary Hoffman Posted January 1, 2011 Posted January 1, 2011 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.
dansmith65 Posted January 1, 2011 Posted January 1, 2011 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');
Genx Posted February 16, 2011 Posted February 16, 2011 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"); }
dansmith65 Posted February 17, 2011 Posted February 17, 2011 oops! he said 'add' didn't he? And off I went, rambling about looping through a found set. he even wrote ADD in caps! :B
Recommended Posts
This topic is 5284 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 accountSign in
Already have an account? Sign in here.
Sign In Now