Saudaçoes

a lista já me ajudou muito, por isso posto aqui um CRUD genérico que usamos
aqui na Tribo
ele tem me ajudado em muita coisa e espero que seja útil tbm a alguém :

<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/
class crud_model extends Model {
    function _construct() {
        parent::Model();
        $this->load->database();
    }
    function inserir($table, $array) {
        $this->db->insert($table, $array);
        return true;
    }
    function atualizar($table, $id_name, $array) {
        $this->db->where($id_name,$array[$id_name]);
        $this->db->update($table, $array);
        return true;
    }
    function deletar($table, $id_name, $array) {
        $this->db->where($id_name,$array[$id_name]);
        $this->db->delete($table);
        return true;
    }
    function mostrar($table) {
        $query = $this->db->get($table);
        return $query;
    }
    function mostrar_onde($table, $array) {
        $query = $this->db->get_where($table, $array);
        return $query;
    }

    function mostrar_ordenado($table, $array, $col, $how) {
        $this->db->select('*');
        $this->db->from($table);
        $this->db->where($array);
        $this->db->order_by($col, $how);
        $query = $this->db->get();
        return $query;
    }


}
?>


-- 
Cliff Oliveira
www.tribodeideias.com.br
_______________________________________________
Lista mailing list
[email protected]
http://codeigniter.com.br/mailman/listinfo/lista_codeigniter.com.br

Responder a