Código PHP:
<?php
class ManejadorDb
{
// Constructor
public function __construct($server,$user,$pass,$db)
{
if(!$this->db = mysql_connect($server,$user,$pass,$db)){
echo "No hay coneccion a la DB";
}else{
return $db;
}
}
//Funcion algo
public function Algo()
{
$query = "SELECT * FROM departamentos";
$this->db = mysql_query($query) or die ("MALA ONDAAAA");
return $db;
}
//Funcion desconectarse
function Desconectarse()
{
$this->db->mysql_close;
}
}
?>