Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Model :
- function insert_data($data) {
- // Jika Foto Ada semua
- if (!empty($_FILES['userfile']['name']) && !empty($_FILES['userfile1']['name'])) {
- $query = 'INSERT INTO restaurant SET nama_restaurant = ?, deskripsi = ?, foto1 = ?, foto2 = ?';
- // Jika Foto 1, Foto 2 Kosong
- } elseif (!empty($_FILES['userfile']['name']) && empty($_FILES['userfile1']['name'])) {
- $query = 'INSERT INTO restaurant SET nama_restaurant = ?, deskripsi = ?, foto1 = ?';
- // Jika Foto 2, Foto 1 Kosong
- } elseif (empty($_FILES['userfile']['name']) && !empty($_FILES['userfile1']['name'])) {
- $query = 'INSERT INTO restaurant SET nama_restaurant = ?, deskripsi = ?, foto2 = ?';
- // Jika Tidak Ada Foto
- } elseif (empty($_FILES['userfile']['name']) && empty($_FILES['userfile1']['name'])) {
- $query = 'INSERT INTO restaurant SET nama_restaurant = ?, deskripsi = ?';
- }
- $query = $this->db->query($query, $data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement