Hola mira yo lo haria asi:
Código PHP:
<?php
class fool{
private $conexion;
public function __construct(){
$this->conexion = mysql_connect('host','user','pass');
mysql_select_db('db');
}
public function mostrar(){
$sql = "select id, titulo, contenido from post";
$resul = mysql_query($sql,$this->conexion);
if ($resul){
while($tmp = mysql_fetch_assoc($resul)){
$return[] = $tmp;
}
return $return;
} else {
return mysql_error();
}
}
}
$fool = new fool();
$tmp = $fool->mostrar();
echo "<pre>";
if (is_array($tmp)){
foreach ($tmp as $a=>$b){
echo $b['id']." ".$b['titulo']." ".$b['contenido']."\n";
}
} else {
echo $tmp;
}
echo "</pre>";
Espero q te sea de ayuda. Saludos.