Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

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 231

Fatal 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? 

Posted

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();
}

 

  • Like 1

This topic is 3372 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
×
×
  • Create New...

Important Information

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