Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
node_load is returning the wrong value
$property = node_load($property_id, NULL, TRUE);
echo $property_id;
print_r($property);
$result = db_query('SELECT * FROM field_data_field_status where entity_id = ' . $property_id);
foreach($result as $item) {
echo $item->field_status_value;
}
$property_id is holding the correct Id number
field_status as part of print_r($property); contains published which is incorrect
echo $item->field_status_value; says paused which is correct
Any ideas why node_load is picking up an incorrect value for field_status please?
Thanks
Comments
I was using db_update to
I was using db_update to store the value in field_status_value Once I changed it to
$property = node_load($nid);
$property->field_status[$property->language][0]['value'] = 'paused';
node_save($property);
node_load picked up the correct value - phew