如果它不为空,创建一个替换mysql值的函数?

I have two keys in the database called background-video-lengthand slide_duration. The one called background-video-lengthis not always set, when it is not, it is NULL. If it is anything but NULL I want to transfer the value from background-video-length to slide_durationand replace whatever is set in this one. And another thing, slide_durationisn't always there, when it is empty it is removed, so it must be created if background-video-length value contains anything. If background-video-length is NULL I want to delete slide_duration if it doesn't contain anything previously.

EDIT: I have this code to set the background-video-length in the database:

  $attachment_id = attachment_url_to_postid( $_POST[ 'background-video' ] );
  $video_meta = get_post_meta( $attachment_id , '_wp_attachment_metadata', true );
if( isset( $_POST[ 'background-video' ] ) ) {
  update_post_meta( $post_id, 'background-video-length', $video_meta['length'] ); 
}