Enviado em 14/04/2015 - 11:50h
Bom dia pessoal
<?php
class Mapos_model extends CI_Model {
function __construct() {
parent::__construct();
}
function get($table,$fields,$where='',$perpage=0,$start=0,$one=false,$array='array'){
$this->db->select($fields);
$this->db->from($table);
$this->db->limit($perpage,$start);
if($where){
$this->db->where($where);
}
$query = $this->db->get();
$result = !$one ? $query->result() : $query->row();
return $result;
}
function getById($id){
$this->db->from('usuarios');
$this->db->select('usuarios.*, permissoes.nome as permissao');
$this->db->join('permissoes', 'permissoes.idPermissao = usuarios.permissoes_id', 'left');
$this->db->where('idUsuarios',$id);
$this->db->limit(1);
return $this->db->get()->row();
}
public function alterarSenha($senha,$oldSenha,$id){
$this->db->where('idUsuarios', $id);
$this->db->limit(1);
$usuario = $this->db->get('usuarios')->row();
$this->db->join('permissoes', 'permissoes.idPermissao = usuarios.permissoes_id', 'left');
$this->db->where('idUsuarios',$id);
$this->db->limit(1);
return $this->db->get()->row();
}
public function alterarSenha($senha,$oldSenha,$id){
$this->db->where('idUsuarios', $id);
$this->db->limit(1);
$usuario = $this->db->get('usuarios')->row();
if($usuario->senha != $oldSenha){
return false;
}
else{
$this->db->set('senha',$senha);
$this->db->where('idUsuarios',$id);
return $this->db->update('usuarios');
}
}
#################################################################### BLOCO ORIGINAL
function pesquisar($termo){
$data = array();
// buscando clientes
$this->db->like('nomeCliente',$termo);
$this->db->limit(5);
$data['clientes'] = $this->db->get('clientes')->result();
#########################################################################
#################### bloco com alterações que preciso ##########################
function pesquisar($termo){
$data = array();
// buscando clientes
$this->db->like('nomeCliente','documento',$termo);
$this->db->limit(5);
$data['clientes'] = $this->db->get('clientes')->result();
Como aprovar Pull Requests em seu repositório Github via linha de comando
Como gerar um podcast a partir de um livro em PDF
Automatizando digitação de códigos 2FA no browser
Resolver problemas de Internet
Como compartilhar a tela do Ubuntu com uma Smart TV (LG, Samsung, etc.)
Resolvendo o erro "libQt6Widgets.so.6: cannot open shared object file" no Linux
Como instalar protetores de tela (Debian e derivados)
Conheça a 4Devs, caixa de ferramentas online para desenvolvedores
Como converter um vídeo MP4 para um GIF para publicar no README.md do seu repositório Github
Agora temos uma assistente virtual no fórum!!! (250)