December 1, 200718 yr i am working on a site where i am expecting to get back a single row as the result of a search. i know how to iterate thru all the rows using foreach ($response->getRecords() as $record ) {} and I have used this to get a single record by id $record = $fm->getRecordById('sku_web', $_GET['id']); but i'm just not sure on the syntax to get the first record from the getRecords() array. thanks andy
December 5, 200718 yr hi, I'm using a little trick: If I'm searching for any field which contains an unique value, I use: $records = $result->getRecords(); $record = $records[0]; // There is only the first one ;-) $field = $record->getField('FileMakerField'); Searching a record ID looks like: $data = $fm->getRecordById('layout', $_SESSION['record_id']); $name = $firmendaten->getField('Name',0); Hope, this helps a little bit. /horst
December 6, 200718 yr $data = $fm->getRecordById('la yout', $_SESSION['record_id']); $name = $firmendaten->getField ('Name',0); Probably a typo, should be: $data = $fm->getRecordById('layout', $_SESSION['record_id']); $name = $data->getField ('Name',0); $records = $result->getRecords(); $record = $records[0]; // There is only the first one ;-) $field = $record->getField('FileMakerField'); Works, but i prefer: $record = current($result->getRecords()); $field = $record->getField('FileMakerField');
December 9, 200718 yr Thanks Genx! Of course there was an error in the first part! Thanks for the $record = current($result->getRecords()); /horst
December 29, 200718 yr Author i ended up using code like this... // perform find $result = $cmd->execute(); // get results $records = $result->getRecords(); $records[0]->getField('FName');
Create an account or sign in to comment