CakePHP 1.3 and Firebird

After searching the internet for a decent walk through or tutorial, I came up with very little and so I decided to collate what have learned in this post with the hope that someone else can benefit from it.

Firstly you will need to obtain the datasources plugin from github and stick it in your application’s plugin folder (app/plugins) – make sure you get the master branch and not the 2.0 as it needs to be compatible with your version of CakePHP (1.3 ideally)

The next thing you need to do is edit the databases config file (app/config/database.php):

var $defaultarray(
        'driver' => 'Datasources.DboFirebird'//references the datasources plugin
        'persistent' => false,
        'host' => 'localhost'//the host name of your database
        'login' => 'sysdba',
        'password' => 'masterkey',
        'database' => 'C:\\path\\to\\database.gdb'//path to the database - note the double backslashes
        'prefix' => '',
        //'encoding' => 'utf8',
    );

The two important things you should note of is the driver key-value pair which references the datasource plugin namespace, and secondly the double backslashes for the database file path.

All the models you create for your application should now access the corresponding tables through the FireBird SQL connection.

Patch landed in Firebird 2.5.x and is now possible to use API to do remote backups/restores

Here is the Firebird bug fixed : #CORE-2666
Today you can use the API remotely to create a serverside backup. You can use GBAK to create a remote backup (e.g. via Internet). And Today you can use API to create remote backup, i.e. create a backup serverside and flush it to the client.

Here is the documentation from the doc/README.services_extension

4) Services API extension – running gbak at server side with .fbk at the client.
(Alex Peshkov, 2011-2012)

This way of doing backups is specially efficient when one needs to perform
backup/restore operation for database, located on ther server accessed using
internet, due to serious performance increase.

The simplest way to use this feature is fbsvcmgr. To backup database run
approximately the following:
fbsvcmgr remotehost:service_mgr -user sysdba -password XXX \
action_backup -dbname some.fdb -bkp_file stdout >some.fbk

and to restore it:
fbsvcmgr remotehost:service_mgr -user sysdba -password XXX \
action_restore -dbname some.fdb -bkp_file stdin <some.fbk

Please notice – you can't use "verbose" switch when performing backup because
data channel from server to client is used to deliver blocks of fbk files. You
will get appropriate error message if you try to do it. When restoring database
verbose mode may be used without limitations.

If you want to perform backup/restore from your own program, you should use
services API for it. Backup is very simple – just pass "stdout" as backup file
name to server and use isc_info_svc_to_eof in isc_service_query() call. Data,
returned by repeating calls to isc_service_query() (certainly with
isc_info_svc_to_eof tag) is a stream, representing image of backup file. Restore
is a bit more tricky. Client sends new spb parameter isc_info_svc_stdin to server
in isc_service_query(). If service needs some data in stdin, it returns
isc_info_svc_stdin in query results, followed by 4-bytes value – number of bytes
server is ready to accept from client. (0 value means no more data is needed right
now.) The main trick is that client should NOT send more data than requested by
server – this causes an error "Size of data is more than requested". The data is
sent in next isc_service_query() call in the send_items block, using
isc_info_svc_line tag in tradition form: isc_info_svc_line, 2 bytes length, data.
When server needs next portion, it once more returns non-zero isc_info_svc_stdin
value from isc_service_query().

A sample of how services API should be used for remote backup and restore can be
found in source code of fbsvcmgr.

Microsoft Access killer : LibreOffice Base + Firebird

There is a discussion on the libreoffice-dev about replacing the HSQLDB default database used in libre base with something better and faster than the java based solution:)

* SQLite vs. HSQLDB for base (Lionel)
+ SQLite very sloppy typing can cause serious problems cf.
https://bugs.freedesktop.org/show_bug.cgi?id=38811#c22
+ no date/time datatype.
=> perhaps not a good idea to switch to sqlite longer term
+ without tons of special casing, get lots of
nasty bugs outside string, float
+ a new candidate with sane licensing, sane language,
and code size required – thinking ongoing.
+ our best shot might be firebird
+ MPL license variant
+ feature set looks good

Update : Firebird Driver and Embedded version merged and integreated into LibreOffice git master

node-firebird vs node-firebird-libfbclient (pure JavaScript driver vs Firebird library wrapper)

Denys Khanzhiyev (node-firebird-libfbclient creator) wrote on nodejs mailing list:
I must admit your lib is faster than mine (See the response from Henry (node-firebird creator) , it is the result of the firebird library mode of operation : synchronous vs asynchronous mode of nodejs)

Here is code
https://gist.github.com/2854642

here is ab results

node-firebird-libfbclient:

Concurrency Level: 5
Time taken for tests: 3.346934 seconds
Complete requests: 1000
Total transferred: 885000 bytes
HTML transferred: 821000 bytes
Requests per second: 298.78 [#/sec] (mean)
Time per request: 16.735 [ms] (mean)
Time per request: 3.347 [ms] (mean, across all concurrent requests)
Transfer rate: 258.15 [Kbytes/sec] received

node-firebird:

Concurrency Level: 5
Time taken for tests: 2.928723 seconds
Complete requests: 1000
Total transferred: 885000 bytes
HTML transferred: 821000 bytes
Requests per second: 341.45 [#/sec] (mean)
Time per request: 14.644 [ms] (mean)
Time per request: 2.929 [ms] (mean, across all concurrent requests)
Transfer rate: 295.01 [Kbytes/sec] received

1 113 114 115 116 117 200