<?php 



class DaoEquipe extends conexao {

public function Atualizar(equipe $equipe) {

try {

if ($equipe->getEqu_id() != '') {

$sql = " UPDATE equipe SET
equ_nome = ?,
equ_descricao = ?,
equ_imagem = ?,
equ_status = ?
WHERE equ_id = ? ";

$stmt = self::conectar()->prepare($sql);
$stmt->bindValue(1, $equipe->getEqu_nome());
$stmt->bindValue(2, $equipe->getEqu_descricao());
$stmt->bindValue(3, $equipe->getEqu_imagem());
$stmt->bindValue(4, $equipe->getEqu_status());
$stmt->bindValue(5, $equipe->getEqu_id());


} else {

$sql = " INSERT INTO equipe (equ_nome,equ_descricao,equ_imagem,equ_status)
VALUES (?,?,?,?)";


$stmt = self::conectar()->prepare($sql);
$stmt->bindValue(1, $equipe->getEqu_nome());
$stmt->bindValue(2, $equipe->getEqu_descricao());
$stmt->bindValue(3, $equipe->getEqu_imagem());
$stmt->bindValue(4, $equipe->getEqu_status());


}
if ($stmt->execute()){
return true;
} else
return false;

} catch (Exception $e) {
print "Erro ao tentar atualizar: ".$e;
}

}

public function PesquisarEquipe($codigo){
$sql = " SELECT * FROM equipe WHERE equ_id = ? ";
$stmt = self::conectar()->prepare($sql);
$stmt->bindValue(1, $codigo);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $result;
}

public function ListarEquipe(){
$sql = " SELECT * FROM equipe ORDER BY equ_id ";
$stmt = self::conectar()->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $result;
}


public function ListarEquipeStatus(){
$sql = " SELECT * FROM equipe WHERE equ_status = 'ATIVO' ORDER BY equ_id ";
$stmt = self::conectar()->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $result;
}

	
public function deletar($equ_id){		
$sql = " DELETE FROM equipe WHERE equ_id = ? ";
$stmt = self::conectar()->prepare($sql);
$stmt->bindValue(1, $equ_id); 
$stmt->execute();
}

 
}
