FileMaker PHP API - getField() 未返回所有值

FileMaker PHP API - getField() not returning all values

我有一个 FileMaker PHP 脚本,用于将记录中的数据回显到我的 iOS 应用程序。我刚刚开始使用 FileMaker PHP API,所以在这里我有点无助。

我能够成功连接到我的 FileMaker WebServer 15 并从布局中提取我需要的一半数据。问题是无论出于何种原因,我都无法获得所需的所有数据。我已尝试将 FileMaker 数据库中的数据类型更改为每种可能的不同数据类型,甚至是计算。我试过带空格和不带空格的数据,比如让 $F 变量 = "a123 123 asdf",它仍然只会拉取 select 几个字段的数据。

每当我执行

$layout->listValueLists();

$layout->listFields();

它表明我试图从中检索数据的所有字段都在布局中,但由于某些原因 PHP 脚本无法 return 从所有字段中获取数据。

这是 PHP 脚本:

<?php

require_once('includes/php/FileMaker.php');

$fm = new FileMaker();
$fm->setProperty('database', 'xx123 Master DB');
$fm->setProperty('hostspec', '123.456.789.000');
$fm->setProperty('username', 'fmphp');
$fm->setProperty('password', 'xx123');


$username = $_POST['username'];
$password = $_POST['password'];

$q = $fm -> newFindCommand('Login_Info');
$q -> addFindCriterion('username', '=='.$username);
$q -> addFindCriterion('password', '=='.$password);

$r = $q->execute();

// This is the login portion of the script
if(empty($username) or empty($password)){

    echo '{"message":"User or password field blank", "code":401}';

}elseif(FileMaker::isError($r)){

    if($r->code == 401){
        echo '{"message":"User not found or password incorrect", "code":401}';
    }else{
        echo '{"message":"Unknown Error", code:'.$r->code.'}';
    }

}else{
// This happens if an account has a $username and $password that are found together.
    $account = $r -> getFirstRecord();
    $ID_Account = $account->getField('ID_Account');
    $customername = $account->getField('Customer_Name');
    $username = $account->getField('username');
    $F = $account->getField('ID_Account_F');
    $customername2 = $account->getField('vCustomer_Name');
    $testpull = $account->getField('testpull');
    $logindata = array('ID_Account' => $ID_Account, 'Customer_Name' => $customername, 'User_Name' => $username, 'F_ID' => $F, 'Customer_Name2' => $customername2, 'testpull' => $testpull);
    echo json_encode($logindata);

}

?>

这是什么脚本returns:

Response: <NSHTTPURLResponse: 0x170221ba0> { URL: http://xx123.com/testing.php } { status code: 200, headers {
    Connection = "keep-alive";
    "Content-Length" = 114;
    "Content-Type" = "text/html";
    Date = "Tue, 13 Dec 2016 17:02:55 GMT";
    "MS-Author-Via" = DAV;
    Server = "Sucuri/Cloudproxy";
    "X-Sucuri-ID" = xx123;
} }
Data: 114 bytes
JSON: ["F_ID": act1207, "User_Name": test, "Customer_Name": , "Customer_Name2": , "testpull": , "ID_Account": 1002]

Here's my layout

您忘记检查您的 fmphp webaccess 帐户中的所有权限!

如果你像我一样忘记了这么简单的事情,记得去

File > Manage > Security > [Account] > "Edit the privilege set"

根据我的经验,最常见的问题是 FileMaker 布局中缺少该字段,最好的检查方法是在 FileMaker 中打开布局并确保不是这种情况。请注意,FileMaker 可以有多个同名布局。

接下来要检查的是,在 FileMaker 中找到与您在 PHP 中查看的记录相同的记录,并确保数据实际上没有从记录中丢失。

检查缺少数据的字段。它们可能来自相关 table。如果是这种情况,您需要不同的语法来引用它们。

最后,在 FilerMaker 中将字段更改为编辑框。如果它们是下拉菜单,则可能必须使用不同的方法来检索它们。