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.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

Firebird 2.1.5 sub-release is available

Firebird Project is pleased to announce Firebird 2.1.5 – the latest minor release in the Firebird 2.1 series.

Binary kits for Windows, Linux and MacOSX on both 32-bit and 64-bit platforms are immediately available for download. For MacOSX, LIPO (fat client) packages are also included. For the full list of changes please refer to the Release Notes.

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)

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.

1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 5.00 out of 5)

Jaybird undocumented tip : Is there any way to set socket timeouts?

Is there any way to set socket timeouts?
Roman Rokytskyy answered :

-Yes, the property is called so_timeout and is directly passed when the socket is opened (see Socket.setSoTimeout documentation). You can append the property to the JDBC URL after question mark:


– I have added this feature on request for some very special case. In general you don’t need this property, since the server is not supposed to crash and the network is not supposed to break as well, at least not for database applications. So, the solution is to solve the crash, not to add a workaround for it.

ps: soon it will be added to documentation

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)

ANN: 2 new Trace API / FBTM screencasts: Parametrized query detection and enhanced error tracing

Two new Trace API / FB TraceManager screencasts have been made available:

The first is discussing the usage of the Trace API to detect
parametrized query reusage, which allows to check if you are re-using prepared statements in e.g. batch processing scenarios or not.

The second demo discusses the new error/warning tracing capabilities to
be expected in Firebird 2.5.2( and its integration/usage in FB TraceManager.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
1 2 3