Forum Moderators: coopster

Message Too Old, No Replies

PHP and Firebird database

Trying to find examples etc.

         

Reflection

6:58 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



I am having a little trouble finding any kind of php examples working with firebird database. I can find plenty of info on how to install firebird and php but not much on actually working with an already created DB.

Ive found documentation on the php interbase functions but I am not having much luck finding any sort of examples other than generic uncommented function examples from the php manual.

Anyone know of any sites that may have, commented/step by step, examples of using php with firebird, stuff like connecting and executing a query to a stored procedure etc. I want to make sure I understand what I am doing :)

Thanks in advance.

hakre

7:18 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



what is firebird? a database? doesn't there exist a homepage with documentation maybe.

coopster

7:19 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you checked the User Contributed notes? There is an example for getting results back from stored procedure in firebird....

[php.net...]

coopster

7:22 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what is firebird? a database?

h**p://www.ibphoenix.com
Have a look at the link on the left titled: What is Firebird?
It is a database originally developed by Borland, now part of the open source movement.

<edit>Remove markup that made the post look like shouting</edit>

[edited by: coopster at 7:35 pm (utc) on Jan. 21, 2004]

hakre

7:32 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i did not know. seems to be a very interesting database at all. if you're working with a plattform supporting odbc you could use that as workaround maybe. odbc is supported by php [php.net].

coopster

7:33 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I just read my last post, it seems as though I was yelling. Sorry if you took it that way. I was merely trying to enlighten you. My apologies if you took the post as sarcasm -- it by no means was meant that way!

Friends? :)

I edited the previous post to make it friendlier :-)

Reflection

9:56 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



Thanks coopster, perhaps you could help me out with a couple questions I have.

From a user contributed example:

$host = 'localhost:X:/firebird/examples/Employee.gdb';
$username='SYSDBA';
$password='masterkey';

$dbh = ibase_connect ( $host, $username, $password ) or die ("error in db connect");
$stmt="Select * from SHOW_LANGS('SRep',4,'Italy')";
$query = ibase_prepare($stmt);
$rs=ibase_execute($query);
$row = ibase_fetch_row($rs);

echo $row[0];

/* free result */
ibase_free_query($query);
ibase_free_result($rs);

/* close db */
ibase_close($dbh);
?>

Just trying to understand, what appear to be, the standard variable names here: Why is the sql statement variable, named stmt? What does the 'h' stand for in dbh?

$query = ibase_prepare($stmt);

Im not sure I quite understand what the ibase_prepare function does. The php manual says "Prepare a query for later binding of parameter placeholders and execution" what exactly does that mean? Why cant you just use the sql statement($stmt) directly in the ibase_excecute function?

Thanks, Im sure I will have a few more later :)

coopster

11:13 pm on Jan 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Why is the sql statement variable, named stmt?

That is just a variable that the programmer selected, it can be whatever you want.

What does the 'h' stand for in dbh?

$dbh
is once again another variable name selected by the programmer. dbh is a common name for a variable used to create a "database handle".

The database interface (commonly called the DBI) uses a handle to connect to the database, which in turn can be used to create handles for db commands or statements. Prior to executing statements within a database, you have to connect to the database.

OK, preparing a statement:
Databases need to parse and validate SQL statements prior to execution. Syntax as well as valid tables, permissions, etc. need to be verified. If all is well the statement handle is returned. Drivers are allowed to delay this prepare statement step until execution. Some databases just don't have any other ways of doing it.

Reflection

5:37 pm on Jan 22, 2004 (gmt 0)

10+ Year Member



Thanks coopster.

Why is the sql statement variable, named stmt?

That is just a variable that the programmer selected, it can be whatever you want.

Yes I knew that :) I was just wondering why the common naming convention appears to be 'stmt'.