Firebird News

Tuesday, March 17, 2009

databene benerator - added support for firebird

The new freshmeat website is now at version 3.0 and in the new clean interface you can read about this new

.:():..:():..:():.

The true story of Blob on reddit

You can read the true story of blob on reddit also an good thing is to vote if you have an account
Jim Starkey showed me the movie that inspired his boss
in requesting the Blob inside the RDBMS




.:():..:():..:():.

Saturday, March 07, 2009

Redhat/Fedora port in progress for Firebird

Here is the bug with Firebird Port in progress for Fedora/Redhat


.:():..:():..:():.

Installing Firebird on FreeBSD - FFAP (Firebird Apache Php)

By far the easiest way to install Firebird is via a package, or the ports tree.
When people in the FreeBSD community get a package running on FreeBSD, they often submit how they did it as a 'port', back to FreeBSD.
( This saves you working out what configure scripts to change, which make to use (make, gmake, bmake, aimk, etc) )

So we'll follow the road they've already blazed. Of course, feel free to download the source tarball, and get it building yourself, but it could take a while...


If you can't find a pre-compiled binary package on FreeBSD.org, firebirdsql.org, or ibphoenix.com, sync up your ports tree.
(Building it yourself ensure's it's built using optimisations for the processor you're running, too)


once ports tree is updated, do:


code:

cd /usr/ports/databases/firebird2-server
make install



Once this is finished, all dependencies are installed, the database is installed, the startup scripts are in place, the firebird user is added, and we're ready to go.

As the comment at the end of the install process suggests, we should change the password of the sysdba user, so lets do that now.

Starting Firebird
This involves running

code:

/usr/local/etc/rc.d/000.firebird.sh start
killall -HUP inetd


Or, simply reboot

Setting up Firebird's SYSDBA User

code:

cd /usr/local/firebird
./bin/gsec -user SYSDBA -pass masterkey
( the ./bin/ is required if you haven't got /usr/local/firebird/bin in your path )
GSEC> modify SYSDBA -pw

( We might add a user while we're here )
GSEC> add testuser -pw testuser

( Now quit out )
GSEC> quit



Done. Now we're ready for databases. the Firebird runs as the user firebird, thusly needs read/write permissions to a directory to store the databases.
I usually make one called '/usr/db':

code:

mkdir /usr/db
chown firebird /usr/db
chgrp firebird /usr/db
chown 770 /usr/db



There we have a nice, secure little home for our databases.
This directory isn't created by the install,as people will always want their databases stored in a different place, on a different HDD controller, etc.

Lets make a database

using your favourite editor, start a file in your home directory called 'fire1.sql', and in it, put the following:

code:

CREATE DATABASE "localhost:/usr/db/fire1.gdb".
COMMIT.

CREATE TABLE tbl_test1(
str_name VARCHAR(100) NOT NULL,
str_phone VARCHAR(20),
PRIMARY KEY(str_name)
).


Then save, and exit the file

Now, well create the database
( It may pay to put '/usr/local/firebird/bin' in your path, to save using the full path to the binaries every time )

code:

isql -u testuser -p testuser <>
Logging in for the very first time
Lets log in, and have a look. Run:

isql -u testuser -p testuser localhost:/usr/db/fire1.gdb

Database: localhost:/usr/db/fire1.gdb, User: testuser
SQL>

You're in! Lets see what's inside:
( Note. Put a semi-colon at the end of every command. It's the terminator at the moment )


SQL> show tables;
TBL_TEST1
SQL>

Let see how that table's made up:
SQL> show table tbl_test1;
STR_NAME VARCHAR(200) Not Null
STR_PHONE VARCHAR(20) Nullable
CONSTRAINT INTEG_2:
Primary key (STR_NAME)
SQL >

Lovely! put some data in
SQL> insert into tbl_test1 (str_name, str_phone)
CON> values ('henry','12345678');
SQL>

( Note the 'CON>' appears while a statement is continuing )

Let's select everything in the table
SQL> select * from tbl_test1;
STR_NAME STR_PHONE
===== ===
henry 12345678

Lets put some more in
SQL> insert into tbl_test1 (str_name, str_phone)
CON> values ('jane','87654321');
SQL>

Select all
SQL> select * from tbl_test1;
STR_NAME STR_PHONE
==== ========
henry 12345678
jane 87654321

Select henry
select * from tbl_test1 where str_name = 'henry';

select people starting with 'h'
select * from tbl_test where str_name like 'h%';

select the first record
select first 1 * from tbl_test1;

select 1 record, but skip 1
select first 1 skip 1 * from tbl_test1;

select any records with the letter 'e' in them
select * from tbl_test1 where str_name containing 'e';

As you can see, the SQL is very similar to other databases.
Next we will instal the apache to FAP (Firebird,Apache, Php)


portsnap fetch
portsnap extract
Installing apache 2.2
cd /usr/ports/www/apache22/
make install clean

Installing php extension
cd /usr/ports/lang/php5
make install clean
cd /usr/ports/lang/php5-extensions
make install clean
cd /usr/ports/database/php5-interbase
make install clean

We need now to enable the Php and firebird extension for it (interbase.so)

Firstly we will edit apache’s config - this lives in /usr/local/etc/apache22/

Open /usr/local/etc/apache22/httpd.conf in your favroute editior (or nano while your learning to love vi)

Look for this line : LoadModule rewrite_module libexec/apache22/mod_rewrite.so
directly underneath this line add the following 3


LoadModule php5_module libexec/apache22/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Then find this line : DirectoryIndex index.html and change it to DirectoryIndex index.php index.html

After this is done we need to give php an ini - the easiest way to do this is to copy the dist one into place

cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

open /usr/local/etc/php/extensions.ini in your favroute editor and look for this line : extension=interbase.so if it isnt there, add it.

one last change and we are good to go!

open /etc/rc.conf in your text editor of choice and add these lines :


apache2_enable="YES"

once your done reboot and enjoy!



Recomdeded Reading :
1.The Complete FreeBSD Book
2.Free BSD Handbook
I was inspired for the Apache/Php install from this article