<?php
class Button_model extends CI_Model {

    public function __construct()
    {
        $this->load->database();
    }
    
    public function get_button()
    {  
        $this->db->order_by ( 'button_level', "asc" ); 
        $this->db->order_by ( 'button_id', "asc" );
        $query = $this->db->get('button');
         return $query->result ();
    }    

    public function get_one_button($_id){
        $query = $this->db->get_where('button', array('button_id' => $_id));
        return $query->row_array();
    }
    
    public function update_button($_id,$_data){
        $this->db->where('button_id',$_id);
        $this->db->update("button",$_data);
        return $this->db->affected_rows();
    }
    public function add_button($_data){
        $this->db->insert("button",$_data);
        return $this->db->affected_rows();
    }    
}

