Advertisement
jamboljack

Restaurant_model

Jun 17th, 2014
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. Model :
  2.  
  3.     function insert_data($data) {
  4.         // Jika Foto Ada semua
  5.         if (!empty($_FILES['userfile']['name']) && !empty($_FILES['userfile1']['name'])) {
  6.             $query = 'INSERT INTO restaurant SET nama_restaurant = ?, deskripsi = ?, foto1 = ?, foto2 = ?';        
  7.         // Jika Foto 1, Foto 2 Kosong
  8.         } elseif (!empty($_FILES['userfile']['name']) && empty($_FILES['userfile1']['name'])) {
  9.             $query = 'INSERT INTO restaurant SET nama_restaurant = ?, deskripsi = ?, foto1 = ?';
  10.         // Jika Foto 2, Foto 1 Kosong
  11.         } elseif (empty($_FILES['userfile']['name']) && !empty($_FILES['userfile1']['name'])) {
  12.             $query = 'INSERT INTO restaurant SET nama_restaurant = ?, deskripsi = ?, foto2 = ?';   
  13.         // Jika Tidak Ada Foto                                         
  14.         } elseif (empty($_FILES['userfile']['name']) && empty($_FILES['userfile1']['name'])) {     
  15.             $query = 'INSERT INTO restaurant SET nama_restaurant = ?, deskripsi = ?';  
  16.         }
  17.        
  18.         $query = $this->db->query($query, $data);
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement