Subject | RE: [ib-support] How can you link Firebird to PHP? |
---|---|
Author | Javier RodrÃguez |
Post date | 2002-09-19T16:59:41Z |
For those arround the Interbase and PHP bussines , I'm doing some stuff to
emulate the TQuery TDatabase TDataset and TDBGrid that Borldand shipped in
Delphi in PHP.. hell , maybe someone could come up whith a frm->php tool
later :)
Anyway , here is the code to create a (very) limited TQuery that should make
the deligth of those that come to PHP rigth now.
It's Free , so it may be good :)
----- ibase.inc.php --- start file ---
// Emulacion de una TQuery de Delphi para PHP v0.01 19/9/2002
// (c) Francisco Javier Rodriguez 2002
// Usa y abusa de este codigo , pero no quites estas cuatro lineas :)
// consultor_sis at hotmail.com ; 966516760 at infonegocio.com
<?php
class TQuery
{
var $sql;
var $database;
var $numres; //Numero de resultados en el datasets de la query
var $dataset; // Conjunto de resultados
var $conexion;
function TQuery() //Es una funcion de incializacion , segun parece;
{
}
function sqltext ($sql)
{
$this->sql= $sql;
}
function exec()
{
$this->dataset=ibase_query($this->conexion,$this->sql);
}
function conecta($bbdd,$usuario,$pass)
{
if (!isset($usuario)) $usuario="SYSDBA";
if (!isset($pass)) $pass="masterkey";
$this->conexion = ibase_connect($bbdd,$usuario,$pass,"ISO8859_1",100,1);
}
function resquery()
{
$i = 0;
while (ibase_fetch_row($dataset)) $i++;
$this->numres=$i;
}
}
?>
------- file ends here ---
to test it , as usual...in php...
--- test.php starts here ------
<?PHP
include "ibase.inc.php";
$query = new TQuery();
$query->conecta("127.0.0.1:/home/demo/emp001/demo.gdb","SYSDBA","masterkey")
;
$query->SQLText("Select * from MPLAN");
$query->exec();
// now , you cann access results in $query->Dataset as usual
?>
---- end test.php----
Next thing will be create a fieldbyname method , and some way to attach the
TQuery->Dataset to the now in coding TDBGrid->Dataset
Hope this be of use to someone
(Not to much off-topic i think ... hullo , heLen! )
emulate the TQuery TDatabase TDataset and TDBGrid that Borldand shipped in
Delphi in PHP.. hell , maybe someone could come up whith a frm->php tool
later :)
Anyway , here is the code to create a (very) limited TQuery that should make
the deligth of those that come to PHP rigth now.
It's Free , so it may be good :)
----- ibase.inc.php --- start file ---
// Emulacion de una TQuery de Delphi para PHP v0.01 19/9/2002
// (c) Francisco Javier Rodriguez 2002
// Usa y abusa de este codigo , pero no quites estas cuatro lineas :)
// consultor_sis at hotmail.com ; 966516760 at infonegocio.com
<?php
class TQuery
{
var $sql;
var $database;
var $numres; //Numero de resultados en el datasets de la query
var $dataset; // Conjunto de resultados
var $conexion;
function TQuery() //Es una funcion de incializacion , segun parece;
{
}
function sqltext ($sql)
{
$this->sql= $sql;
}
function exec()
{
$this->dataset=ibase_query($this->conexion,$this->sql);
}
function conecta($bbdd,$usuario,$pass)
{
if (!isset($usuario)) $usuario="SYSDBA";
if (!isset($pass)) $pass="masterkey";
$this->conexion = ibase_connect($bbdd,$usuario,$pass,"ISO8859_1",100,1);
}
function resquery()
{
$i = 0;
while (ibase_fetch_row($dataset)) $i++;
$this->numres=$i;
}
}
?>
------- file ends here ---
to test it , as usual...in php...
--- test.php starts here ------
<?PHP
include "ibase.inc.php";
$query = new TQuery();
$query->conecta("127.0.0.1:/home/demo/emp001/demo.gdb","SYSDBA","masterkey")
;
$query->SQLText("Select * from MPLAN");
$query->exec();
// now , you cann access results in $query->Dataset as usual
?>
---- end test.php----
Next thing will be create a fieldbyname method , and some way to attach the
TQuery->Dataset to the now in coding TDBGrid->Dataset
Hope this be of use to someone
(Not to much off-topic i think ... hullo , heLen! )