我怎么能访问这个值? PHP

时间:2017-11-29 09:18:17

标签: php salesforce

我想要打印:IdNombre_del_paciente__cFecha_de_la_cita__cHora_de_la_cita__c

这是print_r($response);结果:

Object ( 
    [queryLocator] => [done] => 1 [records] => Array ( 
            [0] => SObject Object (
                [type] => 
                    Cita__c [fields] => stdClass Object 
                    ( 
                        [Nombre_del_paciente__c] => 0030O000021cPBuQAM 
                        [Fecha_de_la_cita__c] => 2017-11-28 
                        [Hora_de_la_cita__c] => 15:30 
                    ) 
                [Id] => a000O00000tmZH6QAM 
            )
    ) [size] => 1 
)

我这样做,我可以访问ID值...但我不能接受其他值:

<table>
                                <tr>
                                    <th>ID </th>
                                    <th>Nombre_del_paciente__c</th>
                                    <th>Fecha_de_la_cita__c</th>
                                    <th>Hora_de_la_cita__c</th>
                                </tr>
                                <?php
                                    foreach ($response->records as $record) {
                                        echo '<tr> 
                                                    <td>'.$record->Id.'</td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                            </tr>';
                                    }
                                ?>
                            </table>

我试着这样做:

$record->type->Nombre_del_paciente__c
$record->Cita__c ->Nombre_del_paciente__c
$record->Cita__c['fields'] ->Nombre_del_paciente__c

但我无法访问值

1 个答案:

答案 0 :(得分:1)

您的密钥'type'不是对象数组。你可以试试这个 -

$record->type['fields']->Nombre_del_paciente__c
$record->type['fields']->Fecha_de_la_cita__c
$record->type['fields']->Hora_de_la_cita__c