Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to update but if field is empty not
  2. if ($this->data['file'] == "") {
  3.     unset($this->data['file']);
  4. }
  5.        
  6. $update['description'] = $_POST['description']; //just another field
  7. if($_POST['file']['name'] == "") //check if there's a new file
  8.   $update['filename'] = $this->book->file_name; //current file name
  9. else
  10.   $update['filename'] = $_POST['file']['name']; //new file name in case the user uploaded a new file
  11.  
  12. $this->book->update($update); //update no matter what