我试图在FileMaker中写入现有记录,使用PHP。
我尝试了以下方法来查找和编辑记录,但它根本不写入新数据:
$fm_ = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);
$request = $fm->newFindCommand('INFO');
$request->addFindCriterion('ID', '==' . $_SESSION['on']);
result = $request->execute();
$records = result->getRecords();
foreach($records as $record) {
$record->setField('Confirm', $_SESSION['confirm']);
$result = $record->commit();
}
知道为什么不写吗?
您需要创建一个newEditCommand并执行它。这可能会起作用:
$fm_ = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);
$request = $fm->newFindCommand('INFO');
$request->addFindCriterion('ID', '==' . $_SESSION['on']);
result = $request->execute();
$records = result->getRecords();
foreach($records as $record) {
$editRequest =& $fm->newEditCommand('INFO', $record->getRecordId() );
$editRequest->setField('Confirm',$_SESSION['confirm']);
$result = $editRequest->execute();
if (FileMaker::isError($result)) {
echo "<p>Error: " . $result->getMessage() . "<p>";
}
}