class firebird{
var $conexao_id;
function firebird() {
$bd = "localhost:/path/to/database.gdb";
$usr = "SYSDBA";
$snh = "masterkey";
$charset ="ISO8859_1";
# Conecta ao banco de dados
$this->conexao_id = ibase_connect($bd, $usr, $snh, $charset) or die("Erro na conexão: ".ibase_errmsg());
return $this->conexao_id;
}
function consulta($sql){
if($sql != '') {
$resultado = ibase_query($this->conexao_id, sprintf($sql)) or die(ibase_errmsg());
while($item = ibase_fetch_assoc($resultado)){
$items[] = $item;
}
$rows = count($items);
if($rows > 0) {
ibase_free_result($resultado);
return $items;
} else {
return false;
}
} else {
return false;
}
}
function fechar() {
ibase_close($this->$conexao_id);
}
}
This is just the begging, I'm planning to convert all my functions to OOP and try to make them as much reusable as possible :)
Nenhum comentário:
Postar um comentário