Hello everyone) Immediately I say, I am a newbie who started studying the YII2 framework a week ago) It so happened that after uni without experience and knowledge I got to work where there is a functioning YII2 website with MySQL database. I was given the task to write to the existing site a couple of pages that will output data from the FireBird database. How can I create an additional connection to the FireBird database? I could not find how to do it. Can anyone tell me how to do this and give a small example of all this?

  • It’s always a good start to consult the firebirdsql.org/manual/ru/qsg15-databases-ru.html documentation - labris
  • This is addressed, it is not that. Here it is in the framework itself. How to implement it on it? Because this framework is very naughty with this database. - Sanvirtus
  • one
    Here is an article that helped me realize this: habrahabr.ru/post/283222 - Sanvirtus

1 answer 1

Access to the Firebird database from YII2 can be accomplished using one of the extensions. The first yii2-firebirddb from Sergey Rusakov , the second yii2-firebird from Edgard Lorraine Messias . I implemented with the help of the second. Install the extension through composer. To do this, open the composer.json file in the main project folder and add the following line to the field:

"require": { .... "edgardmessias/yii2-firebird": "*" .... 

Then we execute 2 commands in the console in turn:

 composer update composer install 

After installation, open the main.php or main-local.php file and register a new connection:

  'db2' => [ 'class' => 'edgardmessias\db\firebird\Connection', 'dsn' => 'firebird:dbname=123.123.123.123:FDB;charset=WIN1251', 'username' => 'SYSDBA', 'password' => 'masterkey' ], 

In short about the line: 'dsn' => 'firebird:dbname=ip адрес:название базы данных;charset=WIN1251',

And that's it, the connection is ready. More detailed instructions can be found on the GitHub links above.