我有一个对象($ node)。我需要更新对象属性的值,我首先取消设置然后更新它
unset($node->field_the_tranasction_status[LANGUAGE_NONE][0]);
$node->field_the_tranasction_status[LANGUAGE_NONE][0]['tid']=97;
但是,如果我之后使用print_r($ node)打印$ node对象,则属性field_the_tranasction_status会出现如下两次,这在调用save()函数时会给我带来问题:
stdClass Object
(
[vid] => 1794
[uid] => 1
[title] => 2222 - 1
[status] => 0
[comment] => 0
[promote] => 0
[sticky] => 0
[nid] => 1471
[type] => donations
[language] => en
[created] => 1495892029
[changed] => 1495892068
[tnid] => 0
[translate] => 0
[revision_timestamp] => 1495892029
[revision_uid] => 1
[field_authorization_code] => Array
(
[und] => Array
(
[0] => Array
(
[value] =>
)
)
)
[field_amount] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 1
)
)
)
[field_currency_iso] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 840
)
)
)
[field_postal_address] => Array
(
[und] => Array
(
[0] => Array
(
[country] => PS
[administrative_area] =>
[sub_administrative_area] =>
[locality] => 2222
[dependent_locality] =>
[postal_code] =>
[thoroughfare] => 222
[premise] =>
[sub_premise] =>
[organisation_name] =>
[name_line] =>
[first_name] =>
[last_name] =>
[data] =>
)
)
)
[field_donor_name] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 2222
[format] =>
[safe_value] => 2222
)
)
)
[field_credit_card_number] => Array
(
[und] => Array
(
[0] => Array
(
[value] => XXXXXXXXXXXX1111
)
)
)
[field_reference_number] => Array
(
[und] => Array
(
[0] => Array
(
[value] => null
)
)
)
[field_signature] => Array
(
[und] => Array
(
[0] => Array
(
[value] => null
)
)
)
[field_response_code] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 2
)
)
)
[field_reason_code] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 513
)
)
)
[field_signature_verified] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 1
)
)
)
[field_reason_description] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 3D Secure Message does not exist
)
)
)
[field_serial] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 135
)
)
)
[field_email] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 21312312@ksdasd.com
[format] =>
[safe_value] => 21312312@ksdasd.com
)
)
)
[field_phone] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 2222
[format] =>
[safe_value] => 2222
)
)
)
[field_anonymous] => Array
(
[und] => Array
(
[0] => Array
(
[value] => 0
)
)
)
[field_campaign] => Array
(
)
[field_perk] => Array
(
)
[field_donation_program] => Array
(
[und] => Array
(
[0] => Array
(
[tid] => 96
)
)
)
[field_processed] => Array
(
[und] => Array
(
[0] => Array
(
[value] => No
)
)
)
[field_referral_url] => Array
(
[und] => Array
(
[0] => Array
(
[value] => https://www.taawon.org/donate
[format] =>
[safe_value] => https://www.taawon.org/donate
)
)
)
[field_transaction_status] => Array
(
)
[field_the_tranasction_status] => Array
(
[und] => Array
(
[0] => Array
(
[tid] => 101
)
)
)
[name] => admin
[picture] => 0
[data] => b:0;
[field_the_tranasction_status] => Array
(
[und] => Array
(
[0] => Array
(
[tid] => 98
)
)
)
[timestamp] => 1495892068
[publish_on] => 0
[unpublish_on] => 0
[xmlsitemap] => Array
(
[id] => 1471
[type] => node
[subtype] => donations
[loc] => node/1471
[language] => en
[access] =>
[status] => 0
[status_override] => 0
[lastmod] => 1495892068
[priority] => 0.5
[priority_override] => 0
[changefreq] => 0
[changecount] => 0
[status_default] => 0
[priority_default] => 0.5
)
)