To use this package:
Install the Firebird PDO driver for PHP.
Mariuz's Blog has a very good step by step on this: http://mapopa.blogspot.com/2009/04/php5-and-firebird-pdo-on-ubuntu-hardy.html
Install using composer:
composer require sim1984/laravel-firebird
Update the app/config/app.php
, add the service provider:
'Firebird\FirebirdServiceProvider'.
For Laravel 5.7 and later:
Firebird\FirebirdServiceProvider::class,
You can remove the original DatabaseServiceProvider, as the original connection factory has also been extended.
Declare your connection in the database config, using 'firebird' as the connecion type. Other keys that are needed:
'firebird' => [
'driver' => 'firebird',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE','/storage/firebird/APPLICATION.FDB'),
'username' => env('DB_USERNAME', 'sysdba'),
'password' => env('DB_PASSWORD', 'masterkey'),
'charset' => env('DB_CHARSET', 'UTF8'),
'role' => 'RDB$ADMIN',
'engine_version' => '3.0.4',
],
And add to your .env
DB_CHARSET=UTF8
If necessary, change the UTF8 to any other charset
This package is a branch jacquestvanzuydam/laravel-firebird package and extends its functionality. Tested on Laravel-5.7.
Added the following features:
- Added support for direct control sequences in
// CREATE SEQUENCE "seq_users_id"
Schema::createSequence('seq_users_id');
// ALTER SEQUENCE "seq_users_id" RESTART WITH 10 INCREMENT BY 5
Schema::sequence('seq_users_id', function (SequenceBlueprint $sequence) {
$sequence->increment(5);
$sequence->restart(10);
});
// DROP SEQUENCE "seq_users_id"
Schema::dropSequence('seq_users_id');
-
The implementation of auto-increment columns in two ways:
-
through the automatic generation of sequences and before insert trigger
// CREATE TABLE "users" (
// "id" INTEGER NOT NULL PRIMARY KEY,
// "name" VARCHAR(255) NOT NULL,
// "email" VARCHAR(255) NOT NULL,
// "password" VARCHAR(255) NOT NULL,
// "remember_token" VARCHAR(100),
// "created_at" TIMESTAMP,
// "updated_at" TIMESTAMP
// );
// ALTER TABLE "users" ADD PRIMARY KEY ("id");
// ALTER TABLE "users" ADD CONSTRAINT "users_email_unique" UNIQUE ("email");
// CREATE SEQUENCE "seq_users";
// CREATE OR ALTER TRIGGER "tr_users_bi" FOR "users"
// ACTIVE BEFORE INSERT
// AS
// BEGIN
// IF (NEW."id" IS NULL) THEN
// NEW."id" = NEXT VALUE FOR "seq_users";
// END
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
// DROP TABLE "users";
// DROP SEQUENCE "seq_users";
Schema::drop('users');
- using identity fields (only in Firebird 3.0).
// CREATE TABLE "users" (
// "id" INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
// "name" VARCHAR(255) NOT NULL,
// "email" VARCHAR(255) NOT NULL,
// "password" VARCHAR(255) NOT NULL,
// "remember_token" VARCHAR(100),
// "created_at" TIMESTAMP,
// "updated_at" TIMESTAMP
// );
// ALTER TABLE "users" ADD CONSTRAINT "users_email_unique" UNIQUE ("email");
Schema::create('users', function (Blueprint $table) {
$table->useIdentity(); // only Firebird 3.0
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
-
The implementation of InsertGetId method is similar to the postgres, ie using RETURNING proposal.
-
Create your own base model class in which insertAndSetId method is implemented through the prior receipt by the sequence identifier.
-
Added additional methods for the execution of stored procedures and stored functions.
-
Added Providing the connection parameters: the name of the role and Firebird version (to use the correct grammar).