Isso é php. <?php ob_start(); header("Content-Type: text/html; charset=ISO-8859-1", true);
class DB {
private $server;
private $db;
private $user;
private $pass;
public $conexao;
public $conexao2;
public $conexao3;
public $baseurl;
function __construct() {
$this->server="localhost";
$this->db="teste";
$this->user="root";
$this->pass="";
$this->Conectar();
}
function Conectar(){
$this->conexao=mysql_connect($this->server,$this->user,$this->pass) or die('Erro ao se conectar');
$this->conexao2=mysql_connect($this->server,$this->user,$this->pass) or die('Erro ao se conectar');
$this->conexao3=mysql_connect($this->server,$this->user,$this->pass) or die('Erro ao se conectar');
mysql_select_db($this->db,$this->conexao) or die('Erro ao selecionar a DB');
mysql_select_db($this->db,$this->conexao2) or die('Erro ao selecionar a DB');
mysql_select_db($this->db,$this->conexao3) or die('Erro ao selecionar a DB');
}
function PesquisaTabela($tabela){
return mysql_query("Select * from $tabela",$this->conexao2);//por exemplo
}
function PesquisaCampos($campos, $tabela){
return mysql_query("Select $campos from $tabela",$this->conexao);//Por exemplo
}
function PesquisaUnica($tabela,$id="0"){
//echo "Select * from $tabela where id=$id";
return(mysql_fetch_array(mysql_query("Select * from $tabela where id=$id")));
}
function ExecutaQuery($query){
return mysql_query($query);
}
function Nlinhas($query){
return mysql_num_rows($query);
}
function ListarCampos($tabela)
{
$result = mysql_query("SHOW COLUMNS FROM ".$tabela);
$field = "";
while($resultado=mysql_fetch_array($result)) {
//print_r($resultado);
foreach($resultado as $campo=>$valor){
if($campo=='0')
$field.=$valor.",";
}
}
return $field;
}
}
?> è isso ai ^_^