<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Alternativa_m extends CI_Model {
    
    function __construct() {
        parent::__construct();
    }
    
    public function add_alternativa($data) {
        $res = $this->db->insert('alternativa', $data);
        
        if($res){
            return $this->db->insert_id();
        }else{
            return FALSE;
        }
    }
    
    public function get_alternativa($id) {
        $this->db->where('id', $id);
        $res = $this->db->get('alternativa')->result();
        
        if(isset($res)){
            return $res;
        }else{
            return FALSE;
        }
    }
    
    public function update_alternativa($id, $data) {
        $this->db->where('id', $id);
        $res = $this->db->update('alternativa', $data);
        
        if(isset($res)){
            return $res;
        }else{
            return FALSE;
        }
    }
    
    public function delete_alternativa($id) {
        $this->db->where('id', $id);
        $res = $this->db->delete('alternativa')->result();
        
        if($res){
            return TRUE;
        }else{
            return FALSE;
        }
    }
    
    public function get_todas() {
        $res = $this->db->get('alternativa')->result();
        
        if($res){
            return $res;
        }else{
            return FALSE;
        }
        
    }
    
    

}
