Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ==================================
- = ../config/database.php
- ==================================
- $db['default'] = array(
- 'dsn' => '',
- 'hostname' => 'localhost',
- 'username' => '<<USER_DB>>',
- 'password' => '<<PASS_DB>>',
- 'database' => '<<NAMA_DB>>',
- 'dbdriver' => 'postgre',
- 'dbprefix' => '',
- 'pconnect' => FALSE,
- 'db_debug' => (ENVIRONMENT !== 'production'),
- 'cache_on' => FALSE,
- 'cachedir' => '',
- 'char_set' => 'utf8',
- 'dbcollat' => 'utf8_general_ci',
- 'swap_pre' => '',
- 'encrypt' => FALSE,
- 'compress' => FALSE,
- 'stricton' => FALSE,
- 'failover' => array(),
- 'save_queries' => TRUE
- );
- =========================================
- = index.php
- =========================================
- define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production');
- ==========================================
- = models untuk hapus record
- ==========================================
- function hapus($item)
- {
- $this->db->where($this->primary_key,$item);
- $this->db->delete($this->table_name);
- }
- =========================================
- = controllers (fungsi delete)
- =========================================
- public function delete()
- {
- $id = $this->input->post('id');
- $this->model_name->hapus($id);
- //gunakan fungsi error untuk mengambil error yang terjadi
- $error = $this->db->error();
- if ($error['message']=='') {
- $result = array('success'=>TRUE);
- echo json_encode($result);
- } else {
- $result = array('errorMsg' =>$error['message']);
- echo json_encode($result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement