【问题标题】:FileMaker PHP API - getField() not returning all valuesFileMaker PHP API - getField() 不返回所有值
【发布时间】:2016-12-14 22:45:58
【问题描述】:

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

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

每当我执行一个

$layout->listValueLists();

$layout->listFields();

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

这是 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);

}

?>

这是脚本返回的内容:

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

【问题讨论】:

    标签: php filemaker


    【解决方案1】:

    你忘了检查你的 fmphp 网络访问帐户中的所有权限!

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

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

    【讨论】:

      【解决方案2】:

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

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

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

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

      【讨论】:

      • 是的,我最终自己完成了这份清单。我快疯了!最终的解决方案是我用于 PHP 访问的帐户中的一半字段缺少读取权限。
      猜你喜欢
      • 1970-01-01
      • 2012-12-07
      • 1970-01-01
      • 2022-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      相关资源
      最近更新 更多