• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Database Error Occurred

#1
[eluser]zacksyah[/eluser]
Code:
<?php

class Bps extends CI_Controller {
    //put your code here

    function __construct(){
        parent::__construct();
        $this->load->library('pagination');
        $this->load->database();
        $this->load->model('bpsmodel');
    }
    
    
    function tampil($offset=0){
        $limit = 10;
        $uri_segment = 3;
        
        $config['base_url']=site_url('bps/tampil');
                $config['total_rows']=$this->bpsmodel->countdata('ukm');
                $config['per_page']=$limit;
                $config['uri_segment']=$uri_segment;
                $config['full_tag_open'] = '';
                $config['full_tag_close'] = '';
                $this->pagination->initialize($config);
                $data['pagination']=$this->pagination->create_links();
                
                $data['title'] = 'Test pagination';
                $data['detail'] = $this->bpsmodel->get('ukm', $config['per_page'], $this->uri->segment(3));
                $this->load->view('bpsview', $data);
    }
    
    
}

?>
Code:
<?php

class Bpsmodel extends CI_Model{
    //put your code here
    
    function __construct(){
        parent::__construct();      
                
        }
        public $table = 'ukm';
        
    function countdata($table){
                           $this->db->SELECT('ukm.id_pengusaha,propinsi.nama_propinsi,
            kecamatan.nama_kecamatan,  
            desa.nama_desa,
            ukm.NBS,
            ukm.NSBS,
            ukm.NUS,
            sampel.nama_sampel,
            ukm.NAMA,ukm.ALAMAT,
            ukm.RT,
            ukm.RW,
            ukm.KODEPOS,
            ukm.TELEPON,
            ukm.EXT,
            ukm.FAX,
            ukm.EMAIL,
            ukm.HOMEPAGE,
            ukm.kegiatan,
            tbl_kategori.nama_kategori,
            kbli.label,
            ukm.nama_pengusaha'   );
                           $this->db->FROM($this->table);
                           $this->db->JOIN('desa','ukm.id_desa = desa.id_desa');
                           $this->db->JOIN('kecamatan','desa.id_kecamatan = kecamatan.id_kecamatan');
                           $this->db->JOIN('kabupaten','kecamatan.id_kabupaten = kabupaten.id_kabupaten');
                           $this->db->JOIN('propinsi','kabupaten.id_propinsi = propinsi.id_propinsi');
                           $this->db->JOIN('kbli','ukm.kode_kbli = kbli.kode_kbli');
                           $this->db->JOIN('tbl_kategori','kbli.kode_kategori = tbl_kategori.kode_kategori');
                           $this->db->JOIN('sampel','ukm.jenis_sampel = sampel.jenis_sampel');
                          
                           $this->db->from($this->table);
                           $res = $this->db->get();
                           return $res->num_rows();
    }
    
    public function get($table,$limit=10,$offset=0){
        $this->db->SELECT(
            'ukm.id_pengusaha,
            propinsi.nama_propinsi,
            kabupaten.nama_kabupaten,  
            kecamatan.nama_kecamatan,  
            desa.nama_desa,
            ukm.NBS,
            ukm.NSBS,
            ukm.NUS,
            sampel.nama_sampel,
            ukm.NAMA,ukm.ALAMAT,
            ukm.RT,
            ukm.RW,
            ukm.KODEPOS,
            ukm.TELEPON,
            ukm.EXT,
            ukm.FAX,
            ukm.EMAIL,
            ukm.HOMEPAGE,
            ukm.kegiatan,
            tbl_kategori.nama_kategori,
            kbli.label,
            ukm.nama_pengusaha'
        );
        $this->db->FROM($this->table);  
        $this->db->JOIN('desa','ukm.id_desa = desa.id_desa');
        $this->db->JOIN('kecamatan','desa.id_kecamatan = kecamatan.id_kecamatan');
        $this->db->JOIN('kabupaten','kecamatan.id_kabupaten = kabupaten.id_kabupaten');
        $this->db->JOIN('propinsi','kabupaten.id_propinsi = propinsi.id_propinsi');
        $this->db->JOIN('kbli','ukm.kode_kbli = kbli.kode_kbli');
        $this->db->JOIN('tbl_kategori','kbli.kode_kategori = tbl_kategori.kode_kategori');
         $this->db->JOIN('sampel','ukm.jenis_sampel = sampel.jenis_sampel');
        $query=$this->db->get($table,$limit,$offset);                            
        if($query->num_rows())
            return 'No Result Dumbass'; // some debug to check of there is result or not
        //Query result
        $query->result();
        return $query;
    }
    }
why error with database?
Code:
A Database Error Occurred
Error Number: 1066

Not unique table/alias: 'ukm'

SELECT `ukm`.`id_pengusaha`, `propinsi`.`nama_propinsi`, `kecamatan`.`nama_kecamatan`, `desa`.`nama_desa`, `ukm`.`NBS`, `ukm`.`NSBS`, `ukm`.`NUS`, `sampel`.`nama_sampel`, `ukm`.`NAMA`, `ukm`.`ALAMAT`, `ukm`.`RT`, `ukm`.`RW`, `ukm`.`KODEPOS`, `ukm`.`TELEPON`, `ukm`.`EXT`, `ukm`.`FAX`, `ukm`.`EMAIL`, `ukm`.`HOMEPAGE`, `ukm`.`kegiatan`, `tbl_kategori`.`nama_kategori`, `kbli`.`label`, `ukm`.`nama_pengusaha` FROM (`ukm`, `ukm`) JOIN `desa` ON `ukm`.`id_desa` = `desa`.`id_desa` JOIN `kecamatan` ON `desa`.`id_kecamatan` = `kecamatan`.`id_kecamatan` JOIN `kabupaten` ON `kecamatan`.`id_kabupaten` = `kabupaten`.`id_kabupaten` JOIN `propinsi` ON `kabupaten`.`id_propinsi` = `propinsi`.`id_propinsi` JOIN `kbli` ON `ukm`.`kode_kbli` = `kbli`.`kode_kbli` JOIN `tbl_kategori` ON `kbli`.`kode_kategori` = `tbl_kategori`.`kode_kategori` JOIN `sampel` ON `ukm`.`jenis_sampel` = `sampel`.`jenis_sampel`

Filename: C:\xampp\htdocs\ci\system\database\DB_driver.php

Line Number: 330
please help me, thanks b4


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.