
Veja o exemplo a seguir, acessando uma Base de Dados OpenBASE Local.
O esquema do banco usado neste exemplo é o seguinte:
Banco EXEMPLO 1
nome: PESSOA E
NOMEP(0) U20
IDADE N3
O Script PHP é o seguinte:
<?
$gw_ida="***" ;
$Banco = "C:\\usr\\tsgbd\\tsdic\\EXEMPLO" ;
$nivel = "a" ;
$seguranca = 1 ;
$modo = "2" ;
$Arquivo="PESSOA" ;
//print "Content_Length ==> " . $CONTENT_LENGTH . "\r\n" ;
if (isset($in_nome))
//if ($CONTENT_LENGTH > 0)
{
$com = new COM("OpenBase.OBcom.1") or die("Unable to instanciate Object");
$result=$com->OAbreBancoDeDados($Banco,$nivel,$seguranca,$modo);
// print "Abre ==> " . $result . "\r\n" ;
$result=$com->OObtemRegistrosNoArquivo($Arquivo);
// print "Registros ==> " . $result . "\r\n" ;
$com->OLeRegistroPorChavePrimaria($Arquivo,$in_nome);
$in_nome=$com->OPegaItem($Arquivo,"NOMEP");
$gw_ida=$com->OPegaItem($Arquivo,"IDADE");
$result=$com->OFechaBancoDeDados(0);
}
?>
<HTML>
<BODY>
<h2>Demonstração OpenBASE COM - PHP</h2>
<Form method="post" action="<? echo $SCRIPT_NAME; ?>">
Informe o Nome:
<input type="text" size=20 name="in_nome" value="<?= $in_nome ?>">
<input type="submit" name="in_cont" value="Continua">
<b><br><br>Resultados:<br>
<ul>
<li>Nome ==> <?= $in_nome?><br>
<li>Idade ==> <?= $gw_ida?><br>
<li>Botão ==> <?= $in_cont?></b>
<eul>
</form>
</body>
</html>
