Sesepuh sekalian tanya dunk.. saya kan mau bikin search di web tapi kok error mulu ya gan...
class M_welcome extends Model { function tampil() { //$this->db->from('mahasiswa'); $query = $this->db->get('pegawai'); return $query->result(); } function caridata() { $c = $this->input->POST('cari'); $tipe = $this->input->post('tipe'); $this->db->like($tipe, $c);--->yang ini katanya error $query= $this->db->get('pegawai'); return $query->result(); } }
Comments
like() pada CI
July 13, 2011 by ekopackerjozz, 2 days 6 hours ago
Comment: 8566
Untuk menggunakan sitaks like() aturanya sebagai berikut:
$this->db->like('nama_kolom', 'katakunci');
// Menghasilkan: WHERE nama_kolom LIKE '%katakunci%'
Koding anda:
$c = $this->input->POST('cari');
$tipe = $this->input->post('tipe');
$this->db->like($tipe, $c);
seharusnya:
$this->db->like('cari', $c);
$this->db->like('tipe', $tipe');
//karena $c dan $cari merupakan katakunci hasil dari post
bls:
July 13, 2011 by syabac, 1 day 13 hours ago
Comment: 8577
dan juga seharusnya:
bls jg:
July 13, 2011 by ekopackerjozz, 1 day 12 hours ago
Comment: 8581
iya mas, tapi masi kurang..
seharusnya juga:
$c = $this->input->post('cari');
$tipe = $this->input->post('tipe');
$this->db->like('cari', $c);
$this->db->like('tipe', $tipe');
hehehe..
gw tambahin lagi... $c =
July 14, 2011 by predhtz, 1 day 9 hours ago
Comment: 8586
gw tambahin lagi...
$c = $this->input->post("cari");
$tipe = $this->input->post("tipe");
// kalau mau pale where cari LIKE '%$cari%' AND tipe LIKE '%$tipe%'
$this->db->like(array("cari" => $cari, "tipe" => $tipe));
// atau kalau mau pake where cari LIKE '%$cari%' OR tipe LIKE '%$tipe%'
$this->db->like('cari', $c);
$this->db->or_like('tipe', $tipe');