Advertisement
Guest User

Untitled

a guest
May 25th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.44 KB | None | 0 0
  1. <?php
  2. class Conexao {
  3.  
  4.     public $con;
  5.  
  6.  
  7.     function __construct () {
  8.         try {
  9.             $this->con = new PDO(DBNAME, USER, PASSWORD);
  10.             return $this->con;
  11.         }
  12.         catch ( PDOException $e ) {
  13.             echo 'Falha na conexão: '.$e->getMessage( );
  14.             return false;
  15.         }
  16.     }
  17.  
  18.    
  19.     function __destruct( ) {
  20.         $this->handle = NULL;
  21.     }
  22.  
  23.    
  24.     function getCountArticle($tabela = ''){
  25.         $retorno = $this->con->prepare("SELECT COUNT(*) FROM ".$tabela);
  26.         return $retorno;
  27.     }
  28.    
  29.     function getCountArticleErro($tabela = ''){
  30.         $retorno = $this->con->prepare("SELECT COUNT(*) FROM ".$tabela);
  31.         return $retorno;
  32.     }  
  33.  
  34.    
  35.     function getArticle($tabela = '', $valor = ''){
  36.         $retorno = $this->con->prepare("SELECT id, a_body FROM ".$tabela." WHERE id = ".$valor." LIMIT 1");
  37.         return $retorno;
  38.     }
  39.  
  40.    
  41.     function getMaxFlagArticle($tabela = ''){
  42.         $retorno = $this->con->prepare("SELECT MAX(articles_id) as id FROM ".$tabela);
  43.         return $retorno;
  44.     }  
  45.    
  46.    
  47.     function identificaEncoding($array) {
  48.         ## IDENTIFICA O ENCODING DO CONTEUDO ##
  49.         $erro = 0;
  50.         foreach ($array as $row) {                     
  51.             //$htmlclean = html_entity_decode(strip_tags(preg_replace($search, '', $row['a_body'])));
  52.             $identificacao =  mb_detect_encoding ($row['a_body']);                             
  53.             if (mb_check_encoding($row['a_body'], "UTF-8")) {
  54.                 echo 'USANDO UTF-8  - Ticket nº  ';   
  55.             }else{                     
  56.                 if (mb_check_encoding($row['a_body'], "ISO-8859-1")) { 
  57.                     echo 'USANDO ISO-8859-1  - Ticket nº  ';      
  58.                 }  
  59.              }                             
  60.             if (empty($identificacao)){
  61.                 echo '<font color="red">';
  62.             }
  63.             echo $row['id'];
  64.             echo ' - ';
  65.             echo $identificacao;
  66.             if (empty($identificacao)){
  67.                 echo 'ERRO AO IDENTIFICAR ENCODING</font>';
  68.                 $erro++;
  69.             }    
  70.             echo '</br></br>';                 
  71.         }
  72.         if($erro > 0){
  73.             echo '<h5> NAO FOI POSSIVEL IDENTIFICAR ENCODING EM : '.$erro . ' MSG(s)</h5>';
  74.         }
  75.     }      
  76.  
  77.    
  78.     function setArticleErro($tabela = '', $valor = '') {   
  79.         $retorno = $this->con->prepare("INSERT INTO ".$tabela." (articles_id) VALUES (".$valor.")");
  80.         return $retorno;
  81.     }      
  82.    
  83.    
  84.     function atualizaHtml($campo = '', $tabela = '', $valor = '', $condicao = '') {
  85.         $retorno = $this->con->prepare("UPDATE ".$tabela." SET ".$campo." = '".$valor."' WHERE id = ".$condicao);
  86.         return $retorno;
  87.     }  
  88.  
  89.    
  90.     function delArticleErro($tabela = '', $valor = '') {   
  91.         $retorno = $this->con->prepare("DELETE FROM ".$tabela." WHERE articles_id = ".$valor." LIMIT 1");
  92.         return $retorno;
  93.     }  
  94.    
  95. }
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement