Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Contoh penggunaan Model Query CodeIgniter ala Supian, M :D
- Script : http://pastebin.com/A55pHBZh
- #======================================================
- $this->query->QueryData('name, email', 'users');
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->select('name, email');
- $this->db->get('users');
- #======================================================
- #======================================================
- $where = array('where' => array('username' => $this->session->userdata('username')),'or_where' => false);
- $this->query->QueryData('name, email', 'users', $where);
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->select('name, email');
- $this->db->where('username', 'supian');
- $this->db->get('users');
- #======================================================
- #======================================================
- $where = array('where' => array('username' => 'supian', 'email' => 'privcodes@gmail.com'), 'or_where' => false);
- $this->query->QueryData('name, email', 'users', $where);
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->select('name, email');
- $this->db->where('username', 'supian');
- $this->db->where('email', 'privcodes');
- $this->db->get('users');
- #======================================================
- $where = array('where' => array('username' => 'supian'), 'or_where' => array('email' => 'privcodes@gmail.com'));
- $this->query->QueryData('name, email', 'users', $where);
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->select('name, email');
- $this->db->where('username', 'supian');
- $this->db->or_where('email', 'privcodes');
- $this->db->get('users');
- #======================================================
- #======================================================
- $this->query->QueryData('users_id, contact_id, phone', 'users', false, array('join' => 'contact', 'contact.contact_id = users.users_id', 'type' => 'inner'));
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->select('users_id, contact_id, phone');
- $this->db->from('users');
- $this->db->join('contact', 'contact.contact_id = users.users_id', 'inner');
- $this->db->get();
- #======================================================
- $this->query->QueryData('name, email', 'users', false, false, array('email' => 'id', 'type' => 'DESC'));
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->select('name, email');
- $this->db->order('email', 'DESC');
- $this->db->get('users');
- #======================================================
- #======================================================
- $this->query->QueryData('name, email', 'users', false, false, array('colum' => 'id', 'type' => 'DESC'), array('from' => '0', 'to' => 5));
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->select('name, email');
- $this->db->order('email', 'DESC');
- $this->db->limit(5,0);
- $this->db->get('users');
- #======================================================
- #======================================================
- $where = array('where' => array('code' => 'ABCDEF'),'or_where' => false);
- $this->query->QueryData('status, balance', 'invite_code', $where);
- $numCode = $this->query->GetNumRows();
- $rowCode = $this->query->GetResult();
- echo $numCode; // Menghasilkan jumlah row
- echo $rowCode->status; // Aktif
- echo $rowCode->balance; // 100 Koin
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->select('status, balance');
- $this->db->where('code' => 'ABCDEF');
- $query = $this->get('invite_code');
- $numCode = $query->num_rows();
- echo $numCode; // Menghasilkan jumlah row
- foreach ($query->result() as $rowCode) {
- echo $rowCode->status; // Aktif
- echo $rowCode->balance; // 100 Koin
- }
- #======================================================
- $this->query->InsertData('users', array('id' => 1, 'username' => 'supian'));
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->insert('users', array('id' => 1, 'username' => 'supian'));
- #======================================================
- #======================================================
- $this->query->UpdateData('users', array('last_login' => '26 Juni 1997'), array('id' => 1));
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->where('id', 1);
- $this->db->update('users', array('last_login' => '26 Juni 1997'));
- #======================================================
- #======================================================
- $this->query->DeleteData('users', array('id' => 1));
- #======================================================
- # SAMA DENGAN
- #======================================================
- $this->db->where('id', 1);
- $this->db->delete('users');
- #======================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement