首页 文章

如何从filemaker pro获取多个记录

提问于
浏览
1

表包含1304条记录,但在运行下面给出的脚本后,它只显示最后一条记录1304次 . 所以请帮助我 . 是否有可能从filemaker获取多个记录,我不知道 .

<?php include ("dbaccess.php");?>
<?php
//Create the 'find all' command and specify the layout
$findCommand = $fm->newFindAllCommand('eventsROY');
//Perform the find and store the result
$result = $findCommand->execute();

        //Check for an error
        if (FileMaker::isError($result)) {
            echo "<p>Error: " . $result->getMessage() . "</p>";
            exit;
        }
   //Store the matching records
        $records = $result->getRecords();
//print_r($records);
        echo $cnt =  count($records);
    foreach($records as $rc){

       $time = $rc->getField('time');echo "<pre>";
print_r($time);
echo "<pre>";
}
?>

1 回答

  • 0

    这个问题已经超级老了,所以我不确定它是否仍然存在问题,但如果可能的话,我可以提供帮助 .

    布局 eventsROY 布局上的字段是什么样的?更重要的是,它们都来自布局的本机表事件,还是其中的一些,特别是来自不同的相关表?

    你的结构是正确的 . 我在这里清理了一下:

    <?php 
    include ("dbaccess.php");
    
    //Create the 'find all' command and specify the layout
    $findCommand = $fm->newFindAllCommand('eventsROY');
    
    //Perform the find and store the result
    $result = $findCommand->execute();
    
    //Check for an error
    if (FileMaker::isError($result)) {
        echo "<p>Error: " . $result->getMessage() . "</p>";
        exit;
    }
    
    //Store the matching records
    echo $count = $result->getFetchCount();
    
    foreach($result->getRecords() as $record){
    
        $time = $record->getField('time');
    
        echo "<pre>";
        print_r($time);
        echo "<pre>";
    }
    
    ?>
    

    因此,如果您从 eventsROY 表获得了预期的记录计数,这意味着查询正在运行,并且如果您错误地从时间字段获得,则表示该字段在 eventsROY 布局上可用 .

    我可以看到这种方式反复拉出相同的 time 值的方法是,如果时间是相关表中的字段,并且该相关表的关系使用 eventsROY 表中每条记录的相同相关记录 . 例如,如果您有一个名为 schedule 的表通过笛卡尔联接( X )与 eventsROY 表相关,那么当您从任何 eventsROY 记录中查看 schedule::time 字段时,该值将是相同的,因为它使用的是来自 first 的相关记录 . schedule 表显示值 .

    你应该怎么做才能解决这个问题:

    • 转到FileMaker中的 eventsROY 布局,查看 time 字段是来自 eventsROY 表还是来自不同的相关表

    • 如果它来自 eventsROY 表并且是一个计算,请确保计算正在从 eventsROY 表事件中进行评估(如果它是从另一个可能导致问题的TO进行评估的话)

    • 回到您的php中,尝试使用 print_r($record) 代替您的 print_r($time) ,以确保其余字段也返回预期的响应

相关问题