Advertisement
gislef

m_clientes.php

Nov 14th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class M_clientes extends CI_model {
  4.  
  5.     /*
  6.      * Recupero todos os clientes do cadastro.
  7.      * Se for passado o parâmetro ID do cliente, então recupero somente um cliente
  8.      */
  9.     public function clientes($id_cliente = null) {
  10.            
  11.         if ($id_cliente != null) {
  12.             $this->db->where("id", $id_cliente);
  13.         }
  14.        
  15.         $this->db->order_by("nome");
  16.         return $this->db->get("cad_clientes");
  17.        
  18.     }
  19.    
  20.     /*
  21.      * A função abaixo simplesmente salva os dados do cliente na tabela.
  22.      * Para utilizá-la, é preciso passar o id do cliente e também os dados do cliente já formatados. Veja no controller estes dados.
  23.      */
  24.      public function salvar($id_cliente = null, $dados_cliente = null){
  25.        
  26.         if ($this->db->where("id", $id_cliente)->update("cad_clientes", $dados_cliente))
  27.             return true;
  28.         else
  29.             return false;
  30.        
  31.      }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement