我正在检索存储在变量$ record中的数据库记录。如果我这样做:
echo '<p><pre>'.print_r($record).'</pre></p>';
我得到以下内容:
FileMaker_Record Object
(
[_impl] => FileMaker_Record_Implementation Object
(
[_fields] => Array
(
[Title] => Array
(
[0] => Alaska 24/7
)
[Status] => Array
(
[0] => Popular
)
[Author] => Array
(
[0] => Rick Smolan and David Elliot Cohen
)
[Publisher] => Array
(
[0] => DK Publishing
)
[Cover Photo Credit] => Array
(
[0] => Evan R. Steinhauser, Anchorage Daily News
)
[Description] => Array
(
[0] => The remarkable photographs showcased in Alaska 24/7 are the result of an epic project, America 24/7, which harnessed the talents of more than 25,000 photographers.
)
[Quantity in Stock] => Array
(
[0] => 50
)
[Number of Pages] => Array
(
[0] => 192
)
[Cover Image] => Array
(
[0] => /fmi/xml/cnt/AK-cover.jpg?-db=FMPHP_Sample&-lay=Form%20View&-recid=1&-field=Cover%20Image(1)
)
)
[V5e7ec2d5] => Array
(
)
[_recordId] => 1
[_modificationId] => 2
[_layout] => FileMaker_Layout Object
(
[_impl] => FileMaker_Layout_Implementation Object
(
[_fm] => FileMaker_Implementation Object
(
[V73ee434e] => Array
(
[charset] => UTF-8
[locale] => en
[logLevel] => 3
[hostspec] => 127.0.01
[recordClass] => FileMaker_Record
[prevalidate] =>
[database] => FMPHP_Sample
[username] => admin
[password] => testing123
)
[Vea4b3413] =>
[V9a3dcbce] =>
)
[_name] => Form View
[_fields] => Array
(
[Title] => FileMaker_Field Object
(
[_impl] => FileMaker_Field_Implementation Object
(
[_layout] => FileMaker_Layout Object
*RECURSION*
[_name] => Title
[_autoEntered] =>
[_global] =>
[_maxRepeat] => 1
[_validationMask] => 0
[_validationRules] => Array
(
)
[_result] => text
[_type] => normal
[_valueList] =>
[_styleType] =>
[_maxCharacters] => 0
)
)
[Status] => FileMaker_Field Object
(
[_impl] => FileMaker_Field_Implementation Object
(
[_layout] => FileMaker_Layout Object
*RECURSION*
[_name] => Status
[_autoEntered] =>
[_global] =>
[_maxRepeat] => 1
[_validationMask] => 0
[_validationRules] => Array
(
)
[_result] => text
[_type] => normal
[_valueList] =>
[_styleType] =>
[_maxCharacters] => 0
)
)
[Author] => FileMaker_Field Object
(
[_impl] => FileMaker_Field_Implementation Object
(
[_layout] => FileMaker_Layout Object
*RECURSION*
[_name] => Author
[_autoEntered] =>
[_global] =>
[_maxRepeat] => 1
[_validationMask] => 0
[_validationRules] => Array
(
)
[_result] => text
[_type] => normal
[_valueList] =>
[_styleType] =>
[_maxCharacters] => 0
)
)
[Publisher] => FileMaker_Field Object
(
[_impl] => FileMaker_Field_Implementation Object
(
[_layout] => FileMaker_Layout Object
*RECURSION*
[_name] => Publisher
[_autoEntered] =>
[_global] =>
[_maxRepeat] => 1
[_validationMask] => 0
[_validationRules] => Array
(
)
[_result] => text
[_type] => normal
[_valueList] =>
[_styleType] =>
[_maxCharacters] => 0
)
)
[Cover Photo Credit] => FileMaker_Field Object
(
[_impl] => FileMaker_Field_Implementation Object
(
[_layout] => FileMaker_Layout Object
*RECURSION*
[_name] => Cover Photo Credit
[_autoEntered] =>
[_global] =>
[_maxRepeat] => 1
[_validationMask] => 0
[_validationRules] => Array
(
)
[_result] => text
[_type] => normal
[_valueList] =>
[_styleType] =>
[_maxCharacters] => 0
)
)
[Description] => FileMaker_Field Object
(
[_impl] => FileMaker_Field_Implementation Object
(
[_layout] => FileMaker_Layout Object
*RECURSION*
[_name] => Description
[_autoEntered] =>
[_global] =>
[_maxRepeat] => 1
[_validationMask] => 0
[_validationRules] => Array
(
)
[_result] => text
[_type] => normal
[_valueList] =>
[_styleType] =>
[_maxCharacters] => 0
)
)
[Quantity in Stock] => FileMaker_Field Object
(
[_impl] => FileMaker_Field_Implementation Object
(
[_layout] => FileMaker_Layout Object
*RECURSION*
[_name] => Quantity in Stock
[_autoEntered] =>
[_global] =>
[_maxRepeat] => 1
[_validationMask] => 0
[_validationRules] => Array
(
)
[_result] => number
[_type] => normal
[_valueList] =>
[_styleType] =>
[_maxCharacters] => 0
)
)
[Number of Pages] => FileMaker_Field Object
(
[_impl] => FileMaker_Field_Implementation Object
(
[_layout] => FileMaker_Layout Object
*RECURSION*
[_name] => Number of Pages
[_autoEntered] =>
[_global] =>
[_maxRepeat] => 1
[_validationMask] => 0
[_validationRules] => Array
(
)
[_result] => number
[_type] => normal
[_valueList] =>
[_styleType] =>
[_maxCharacters] => 0
)
)
[Cover Image] => FileMaker_Field Object
(
[_impl] => FileMaker_Field_Implementation Object
(
[_layout] => FileMaker_Layout Object
*RECURSION*
[_name] => Cover Image
[_autoEntered] =>
[_global] =>
[_maxRepeat] => 1
[_validationMask] => 0
[_validationRules] => Array
(
)
[_result] => container
[_type] => normal
[_valueList] =>
[_styleType] =>
[_maxCharacters] => 0
)
)
)
[_relatedSets] => Array
(
)
[_valueLists] => Array
(
)
[Vab234ad8] => Array
(
)
[_database] => FMPHP_Sample
[_extended] =>
)
)
[_fm] => FileMaker_Implementation Object
(
[V73ee434e] => Array
(
[charset] => UTF-8
[locale] => en
[logLevel] => 3
[hostspec] => 127.0.0.1
[recordClass] => FileMaker_Record
[prevalidate] =>
[database] => FMPHP_Sample
[username] => admin
[password] => testing123
)
[Vea4b3413] =>
[V9a3dcbce] =>
)
[_relatedSets] => Array
(
)
[_parent] =>
)
)
我需要做一些检查,看看我所追踪的字段是否存在于$ record对象返回的字段列表中。例如,我想看看字段'Status'是否包含在[_fields] =&gt;中。数组字段列表(在此示例中为true)。
我假设我可以使用这样的东西:
if (in_array('Status', _fields)) {
但不确定这里的确切语法,到目前为止还无法使其工作。
答案 0 :(得分:0)
好像你有一个名为FileMaker_Record_Implementation Object的嵌入对象。如果您可以访问此类的源代码,可能值得一看,因为它可能为其中的属性提供getter / setter。
或者您可以尝试直接访问该属性:
if(!isset($record->_impl->_fields['Status'])){
// Status doesn't exist
}
答案 1 :(得分:0)
您可以使用isset()
或array_key_exists()
函数进行检查,
但他们俩都不一样。
array_key_exists()
仅检查密钥是否存在,即使该值为NULL。
isset()
总是返回false。