Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.