I work with views bulk operations and I wanna change status of selected items in a view. I applied db_update query, but something went wrong. I was debugging my code following:
$status=$context['status'];
foreach($context['rows'] as $order) {
db_update('orders')
->fields(array(
'status' => $status
))
->condition('oid',$order->oid,'=')
->execute();
}
foreach($context['rows'] as $order) {
$result = db_select('orders','status')
->fields('status')
->condition('oid',$order->oid)
->execute()
->fetchAssoc();
if($result) {
drupal_set_message($result['status']);
drupal_set_message($result['oid']);
}
}
So first is db_update and after that I did db_select and printed it out.The result of this db_select behaves like status would be updated. But in the node is status still the same. Also in database it stayed unchanged. I have no idea what's wrong. It behaves like it was updated and then immediately got back.I would be very helpful for any help. Sorry for my english. Thanks.