0

I am trying to develop a custom module; so far it works as it should. The only problem is I can't seem to get the MAC address to remain unchanged on update. It keeps getting the device ID number instead of the MAC field. How do I avoid the MAC address is changed?

function device_delete_request($uid = null, $macaddress, $device_id = null) {
  db_update('argon_user_stuff')
    ->fields(array(
      'id' => $device_id,
      'uid' => $uid,                 
      'macaddress' => $macaddress,
      'deletedmacaddress' => $macaddress,
      'updated' => REQUEST_TIME,
      'deleted' => REQUEST_TIME,
      'active' => 0
    ))
    ->condition('uid', $uid, '=')
    ->condition('id', $device_id, '=')
    ->execute();


    // Set the message and return to the user's profile page
    drupal_set_message('Device deleted');
    return drupal_goto("user/{$uid}/devices");

}
2
  • 1
    Not sure i understood your query completely, but if you need the macaddress to remain unchanged you don't need to have it in the fields list of the update query. Please clarify if I haven't understood your query. Commented May 9, 2017 at 11:34
  • Let me explain it as simply as I can. I have a database that contains the fields above. I want to an update the database field with the values above and replicate the macaddress content on to deletedmacadress. It works perfectly as it is but the macaddress keps getting values for the id field. Commented May 9, 2017 at 17:28

1 Answer 1

0

Is that mac address is a required field? It may be possible mac address passing to this function not getting change, you may need to debug mac address before the function call.

1
  • Yes it is a required field.The macaddress should not be changed. It should just be read and duplicated to deletedmacaddress. Currently it is being changed to the content of id field. Commented May 9, 2017 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.