September 1, 201510 yr Newbies Hello, I'm trying to increment 1 to a value that is already on the database on a layout, but I cannot seem to be able to do it, here is what I did step by step. //Searchs for the field, and saves the value $findCommand = & $fm->newFindCommand('PHP_Prefs'); $findCommand->addFindCriterion('id_prefs', $_SESSION["prefs"]); $result = $findCommand->execute(); $records = $result->getRecords(); foreach ($records as $resultado) { $atual = $resultado->getField('service_ID_serial'); } //Trying to increment 1, withou success $rec =& $fm->newEditCommand('PHP_Prefs'); $rec->addFindCriterion('id_prefs', $_SESSION["prefs"]); $rec->setField('service_ID_serial', $atual+1); $fim = $rec->execute(); And the output error that I get is the following: Warning: Missing argument 2 for FileMaker::newEditCommand(), called in /Users/admin/Sites/service/form_reparacao.php on line 337 and defined in /Users/admin/Sites/service/lib/FileMaker.php on line 231Fatal error: Call to undefined method FileMaker_Command_Edit::addFindCriterion() in /Users/admin/Sites/service/form_reparacao.php on line 338 Do you guys by any chance know how can I solve this situation?
September 1, 201510 yr newEditCommand() requires 2 arguments, the layout and the recordID. It's not clear from your code whether your found set is one record or more than one record. If only one record, you don't need the foreach() loop; you can use $recID = $record[0]->getRecordId(); $atual = $record[0]->getField('service_ID_serial'); $incr = $fm->newEditCommand('PHP_Prefs', $recID); $incr->setField('service_ID_serial', $atual + 1); $fim = $incr->execute(); If more than one record is in the found set foreach($records as $resultado){ $recID = $resultado->getRecordId(); $atual = $resultado->getField('service_ID_serial'); $incr = $fm->newEditCommand('PHP_Prefs', $recID); $incr->setField('service_ID_serial', $atual + 1); $fim = $incr->execute(); }
Create an account or sign in to comment