%PDF- %PDF-
Mini Shell

Mini Shell

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

<?php
session_start();
include_once("../../configuration/config.inc.php");

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

	public function inserir($titulo,$arquivo){
	
		$retorno = array();
			
		$sql = "INSERT INTO cms_videos (titulo, arquivo, status) values (:titulo, :arquivo, :status)";
		
		$vars = array(":titulo" => $titulo, ":arquivo" => $arquivo, ":status" => 1);
		$stmt = $this->pdo->prepare($sql);
		
		if($stmt->execute($vars)){
			return array("msg" => '1');
		} else {
			return array("msg" => '0');
		}
	}
	
	public function listar($filtro){
		
		$retorno = array();
		
		$sql = "SELECT * FROM cms_videos WHERE (titulo LIKE :titulo) AND status <> :status;";
		
		$vars = array (":titulo"=>"%{$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){
		$return = array();
		
		$sql = "SELECT * FROM cms_videos 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 atualizarDados($id,$titulo){
	
		$return = array();
		
		$sql = "UPDATE cms_videos SET titulo = :titulo WHERE id = :id;";
		
		$vars = array(":id"=>$id, ":titulo"=>$titulo);
		
		$stmt = $this->pdo->prepare($sql);
		
		$stmt->execute($vars);
		
		if($stmt->rowCount()){
			return true;
		} else {
			return false;
		}
	
	}

	public function atualizarVideo($id, $arquivo){
	
		$return = array();
		
		$sql = "UPDATE cms_videos SET arquivo = :arquivo WHERE id = :id;";
		
		$vars = array(":id"=>$id, ":arquivo"=>$arquivo);
		
		$stmt = $this->pdo->prepare($sql);
		
		$stmt->execute($vars);
		
		if($stmt->rowCount()){
			return true;
		} else {
			return false;
		}
	
	}
	
	public function excluir($id){
		
		$retorno = array();
		
		$sql = "UPDATE cms_videos SET status = :status WHERE id = :id;";
		
		$vars = array(":id"=>$id,":status"=>'3');
		
		$stmt = $this->pdo->prepare($sql);
			
		$stmt->execute($vars);
		
		if($stmt->rowCount()){
			return array ("msg"=>'1');
		}else{
			return array ("msg"=>'0');
		}
	}
	
	public function listarItem($filtro){
		
		$retorno = array();
		
		$sql = "SELECT * FROM cms_videos WHERE id = :id AND status = :status;";
		
		$vars = array (":id"=>$filtro,":status"=>1);
		
		$stmt = $this->pdo->prepare($sql);
			
		if($stmt->execute($vars)){
			$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');
		}
	}
	
}
?>

Zerion Mini Shell 1.0