%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home1/dimen328/libertysa.com.br/admin/modules/PHPmailer/
Upload File :
Create Path :
Current File : //home1/dimen328/libertysa.com.br/admin/modules/PHPmailer/DAO.php

<?php
// Chama por include a Classe de Conexão que criamos
include_once("../../configuration/config.inc.php");

class DAO {
	
	private $pdo;
	
	public function __construct(){
		$this->pdo = $GLOBALS['pdo'];
	}

	public function inserir($smtpauth,$smtpsecure,$port,$host,$username,$password,$smtpdebug,$status) {
		
		$retorno = array();

		$sql = "INSERT INTO cms_phpmailer (smtpauth, smtpsecure, port, host, username, password, smtpdebug, status ) VALUES (:smtpauth, :smtpsecure, :port, :host, :username, :password, :smtpdebug, :status)"; 
			
		$vars = array(":smtpauth"=>$smtpauth,":smtpsecure"=>$smtpsecure,":port"=>$port,":host"=>$host,":username"=>$username,":password"=>$password,":smtpdebug"=>$smtpdebug,":status"=>$status);
		
		$stmt = $this->pdo->prepare($sql);
		
		foreach($vars as $index => $value){
			$stmt->bindValue($index,$value);
		}
		
		if($stmt->execute()){
			return array("msg" => '1');
		} else {
			return array("msg" => '0');
		}
	}
	
	public function listar($filtro){
	
		$retorno = array();
		
		$sql = "SELECT * FROM cms_phpmailer WHERE username LIKE :username AND status < :status;";
		
		$vars = array(":status"=>3,":username"=>"%{$filtro}%");//,":status"=>"3"
		
		$stmt = $this->pdo->prepare($sql);
		
		foreach($vars as $index => $value){
			$stmt->bindValue($index,$value);
		}
		
		if($stmt->execute()){
			$count = $stmt->rowCount();
			$rows = $stmt->fetchAll(PDO::FETCH_OBJ);
			$rows['msg'] = '1';
			$rows['length'] = $count;
			
			$i = 0;
			while($i < $count){
				foreach($rows[$i] as $index => $value){
					$rows[$i]->$index = utf8_encode($value);
				}
				$i++;
			}
			
			return $rows;
		} else {
			return array("msg" => '0');
		}
	}

	public function preencher($id){
	
		$retorno = array();
		
		$sql = "SELECT * FROM cms_phpmailer WHERE id = :id;";
			
		$vars = array(":id"=>$id);
		
		$stmt = $this->pdo->prepare($sql);
		
		foreach($vars as $index => $value){
			$stmt->bindValue($index,$value);
		}
		
		if($stmt->execute()){
			$rows = $stmt->fetch(PDO::FETCH_OBJ);
			$rows->msg = '1';
			
			foreach($rows as $index => $value){
				$rows->$index = utf8_encode($value);
			}

			return $rows;
		} else {
			return array("msg" => '0');
		}
	}
	
	public function atualizar($id,$smtpauth,$smtpsecure,$port,$host,$username,$password,$smtpdebug,$status){
	
		$retorno = array();
		
		$sql = "UPDATE cms_phpmailer SET smtpauth = :smtpauth, smtpsecure = :smtpsecure, port = :port, host = :host, username = :username, password = :password, smtpdebug = :smtpdebug, status = :status WHERE id= :id;";
			
		$vars = array(":id"=>$id,":smtpauth"=>$smtpauth,":smtpsecure"=>$smtpsecure,":port"=>$port,":host"=>$host,":username"=>$username,":password"=>$password,":smtpdebug"=>$smtpdebug,":status"=>$status);
		
		$stmt = $this->pdo->prepare($sql);
		
		foreach($vars as $index => $value){
			$stmt->bindValue($index,$value);
		}
		
		$stmt->execute();
		
		if($stmt->rowCount()){
			return array("msg" => '1');
		} else {
			return array("msg" => '0');
		}
	}
	
	public function excluir($id){
	
		$retorno = array();
		
		$sql = "UPDATE cms_phpmailer SET status = :status WHERE id = :id;";
			
		$vars = array(":id"=>$id,":status"=>'3');
		
		$stmt = $this->pdo->prepare($sql);
		
		foreach($vars as $index => $value){
			$stmt->bindValue($index,$value);
		}
		
		$stmt->execute();
		
		if($stmt->rowCount()){
			return array("msg" => '1');
		} else {
			return array("msg" => '0');
		}
	}
	
}
?>

Zerion Mini Shell 1.0