Welcome Guest, Not a member yet? Register   Sign In
What the meaning of this word?
#5

[eluser]Freakniube[/eluser]
i don't have any idea what your thingking,because i just try make you easy to read the code but if you like this way here the code....

Code:
<?php
class Modeltamu extends Model {
    
    function Modeltamu()
    {
        parent::Model();
    }
    
    // Inisialisasi nama tabel yang digunakan
    var $table = 'tamu';
    
    /**
     * Menghitung jumlah baris dalam sebuah tabel, ada kaitannya dengan pagination
     */
    function count_all_num_rows()
    {
        return $this->db->count_all($this->table);
    }
    
    /**
     * Tampilkan 10 baris tamu terkini, diurutkan berdasarkan tanggal (Descending)
     */
    function get_last_ten_tamu($limit, $offset)
    {
        $this->db->select('tamu.id_tamu, tamu.tanggal, tamu.bill, guest.nama, bulan.bulan, tamu.tamu');
        $this->db->from('tamu, guest, kamar, bulan');
        $this->db->where('guest.id_kamar = kamar.id_kamar');
        $this->db->where('tamu.bill = guest.bill');
        $this->db->where('bulan.id_bulan = absen.id_bulan');
        $this->db->order_by('tamu.tanggal', 'desc');
        $this->db->limit($limit, $offset);
        return $this->db->get();
    }
    
    /**
     * Menghapus sebuah entry data tamu
     */
    function delete($id_tamu)
    {
        $this->db->where('id_tamu', $id_tamu);
        $this->db->delete($this->table);
    }
    
    /**
     * Menambahkan sebuah data ke tabel tamu
     */
    function add($tamu)
    {
        $this->db->insert($this->table, $tamu);
    }
    
    /**
     * Dapatkan data tamu dengan id_tamu tertentu, untuk proses update
     */
    function get_tamu_by_id($id_tamu)
    {
        $this->db->select('id_tamu, bill, id_bulan, tanggal, tamu');
        $this->db->where('id_tamu', $id_tamu);
        return $this->db->get($this->table);
    }
    
    /**
     * Update data tamu
     */
    function update($id_tamu, $tamu)
    {
        $this->db->where('id_tamu', $id_tamu);
        $this->db->update($this->table, $tamu);
    }
    
    /**
     * Cek apakah ada entry data yang sama pada tanggal tertentu untuk guest dengan bill tertentu pula
     */
    function valid_entry($bill, $tanggal)
    {
        $this->db->where('bill', $bill);
        $this->db->where('tanggal', $tanggal);
        $query = $this->db->get($this->table)->num_rows();
                        
        if($query > 0)
        {
            return FALSE;
        }
        else
        {
            return TRUE;
        }
    }    
}

any way this diffrent from link above.Controltamu.php i changed with tamu.php.
yesterday i try to add more php to CI like guest.php,modelguest.php,formguest.php and few more(of course login page i have add it) but the output not error like this (Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\puri2\system\application\controllers\controltamu.php on line 124)

but change to

A Database Error Occurred

Error Number: 1054

Unknown column 'bulan.bulan' in 'field list'

SELECT `tamu`.`id_tamu`, `tamu`.`tanggal`, `tamu`.`bill`, `guest`.`nama`, `bulan`.`bulan`, `tamu`.`tamu` FROM (`tamu`, `guest`, `kamar`, `bulan`) WHERE `guest`.`id_kamar` = kamar.id_kamar AND `tamu`.`bill` = guest.bill AND `bulan`.`id_bulan` = absen.id_bulan ORDER BY `tamu`.`tanggal` desc LIMIT 10

this morning (gmt7) i try to change the db but i haven't found the problem,but i think the problem is db not the code....
what do you think?
thx for the reply btw


Messages In This Thread
What the meaning of this word? - by El Forum - 02-13-2011, 11:56 PM
What the meaning of this word? - by El Forum - 02-14-2011, 12:07 AM
What the meaning of this word? - by El Forum - 02-14-2011, 12:27 AM
What the meaning of this word? - by El Forum - 02-14-2011, 08:55 AM
What the meaning of this word? - by El Forum - 02-15-2011, 12:16 AM
What the meaning of this word? - by El Forum - 02-15-2011, 12:55 AM
What the meaning of this word? - by El Forum - 02-15-2011, 01:19 AM
What the meaning of this word? - by El Forum - 02-15-2011, 01:40 AM
What the meaning of this word? - by El Forum - 02-16-2011, 07:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB