Advertisement
Googleinurl

Exemplo uso class PDO

Jun 3rd, 2013
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.56 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * To change this template, choose Tools | Templates
  5.  * and open the template in the editor.
  6.  */
  7.  
  8. /**
  9.  * Description of Controleq
  10.  *
  11.  * @author cleiton
  12.  */
  13.  
  14. class Controleq {
  15.  
  16.     private $dados = array();
  17.     private $where = array();
  18.     private $tabela = null;
  19.     private $sql = null;
  20.     private $db;
  21.  
  22.     public function __construct($db) {
  23.         $this->db = $db;
  24.         require_once 'Executaq.class.php';
  25.         require_once 'Filtro.class.php';
  26.     }
  27.  
  28.     //GET SET DADOS
  29.     public function setDados($dados) {
  30.         $this->dados = $dados;
  31.     }
  32.  
  33.     public function getDados() {
  34.         return $this->dados;
  35.     }
  36.  
  37.     //GET SET WHERE
  38.     public function setWhere($where) {
  39.         $this->where = $where;
  40.     }
  41.  
  42.     public function getWhere() {
  43.         return $this->where;
  44.     }
  45.  
  46.     //GET SET TABELA
  47.     public function setTabela($tabela) {
  48.         $this->tablea = $tabela;
  49.     }
  50.  
  51.     public function getTabela() {
  52.         return $this->tabela;
  53.     }
  54.  
  55.     //GET SET SQL
  56.     public function setSql($sql) {
  57.         $this->sql = $sql;
  58.     }
  59.  
  60.     public function getSql() {
  61.         return $this->sql;
  62.     }
  63.  
  64.     //FIM GET SETS\\
  65.  
  66.     //SUB FUNCTION RESPONSAVEL POR GERAR RELATORIOS
  67.     //COM BETWEEN PARAMETROS $tabela $campo arrayDADOS de pesquisa
  68.  
  69.     private function sub_functionRelP($tabela, $campo) {
  70.         $sql = "SELECT * FROM {$tabela} where {$campo} BETWEEN :data_inicio AND :data_fim";
  71.  
  72.         $objFiltro = new Filtro();
  73.         $objExecq = new Executaq($this->db);
  74.         $objExecq->sql = $sql;
  75.  
  76.         $this->dados['data_inicio'] = $this->dados['data_inicio'];
  77.         $this->dados['data_fim'] = $this->dados['data_fim'];
  78.         $objExecq->dados = $this->dados;
  79.  
  80.         return $objExecq->select($sql, $objExecq->dados);
  81.     }
  82.  
  83.    
  84.     public function sMaillingIdUser($dados) {
  85.         //Select pega o mailling de acordo com user.
  86.         //id_usuario, id_mailling
  87.  
  88.         $sql = "SELECT distinct os.id_mailling,os.id_usuario, m.nome_mailling,m.status FROM int_operacao_usuario os
  89.                inner join int_mailling m on m.id_mailling = os.id_mailling
  90.                where m.status = 1 and os.id_usuario =:id_usuario and m.id_operacao=:id_operacao;";
  91.         $objExecq = new Executaq($this->db);
  92.         $objFiltro = new Filtro();
  93.         $objExecq->sql = $sql;
  94.         $objExecq->dados = $objFiltro->numeros($this->dados); // Desconsidere objFiltro é um class que eu criei para filtros de números.
  95.         return $objExecq->select($sql, $objExecq->dados);
  96.     }
  97.  
  98. }
  99.  
  100. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement