Editor with Firebird

Editor with Firebird

baktorbaktor Posts: 6Questions: 2Answers: 0
edited March 2022 in Editor

Hi, I would like to use Editor with Firebird, but I get an error message:

{"error":"An error occurred while connecting to the database 'test'. The error reported by the server was: SQLSTATE[HY000] [335544323] file is not a valid database"}

OR

{"error":"An error occurred while connecting to the database '\/hdd\/teszt\/XXXXX.FDB'. The error reported by the server was: SQLSTATE[HY000] [335544323] file is not a valid database"}

How should I use db param?

$sql_details = array(
"type" => "Firebird", // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite" or "Oracle"
"user" => "username", // Database user name
"pass" => "password", // Database password
"host" => "localhost", // Database host
"port" => "", // Database connection port (can be left empty for default)
"db" => "/hdd/teszt/XXXXX.FDB", // Database name
"dsn" => "", // PHP DSN extra information. Set as charset=utf8mb4 if you are using MySQL
"pdoAttr" => array() // PHP PDO attributes array. See the PHP documentation for all options
);

Thanks,

Viktor

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    I was going to say that we don’t support Firebird, but actually, looking at the drivers, there is a Firebird driver there from four years ago.

    Can you show me how you would normally connect to your Firebird database with PDO and I’ll check that against what Editor does.

    Thanks,
    Allan

  • baktorbaktor Posts: 6Questions: 2Answers: 0
    edited March 2022

    I need to change config.php:

    $sql_details = array(
    "type" => "Firebird",    
    "user" => "username",          
    "pass" => "password",        
    "host" => "", 
    "port" => "",          
    "db"   => "",          
    "dsn"  => "charset=utf8",         
    "pdoAttr" => array()   
    );
    

    and FirebirdQuery.php:

    this line:

    "firebird:{$host}dbname={$db}".self::dsnPostfix( $dsn ),

    to

    "firebird:dbname=serverhost:/hdd/teszt/XXXXXX.FDB".self::dsnPostfix( $dsn )

    It works well.

    A simple script to connect:

    ```
    <?php
    $username = 'username';
    $password = 'password';
    $dsn = 'firebird:dbname=serverhost:/hdd/teszt/XXXXX.FDB';

    try {
      // Connect to database
      $dbh = new \PDO($dsn, $username, $password,
                      [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);
      $sql = 'SELECT * FROM INFO';
      // Execute query
      $query = $dbh->query($sql);
      // Get the result row by row as object
      while ($row = $query->fetch(\PDO::FETCH_OBJ)) {
        echo $row->USER_NEV2, "\n";
      }
      $query->closeCursor();
    } catch (\PDOException $e) {
      echo $e->getMessage();
    }
    
    <?php > ``` ?>

    Thank you for your help,

    Viktor

    Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Answer ✓

    Hi Viktor,

    Many thanks! It looks like if you use:

    $sql_details = array(
      "type" => "Firebird",    
      "user" => "username",          
      "pass" => "password",        
      "host" => "", 
      "port" => "",          
      "db"   => "serverhost:/hdd/teszt/XXXXX.FDB",          
      "dsn"  => "charset=utf8",         
      "pdoAttr" => array()   
    );
    

    Then that should result in a successful connection without modifying the library code?

    Allan

  • baktorbaktor Posts: 6Questions: 2Answers: 0

    Hi Allan,

    In this case got an error:

    {"error":"An error occurred while connecting to the database '\/hdd\/teszt\/XXXXX.FDB'. The error reported by the server was: SQLSTATE[HY000] [335544323] file is not a valid database"}

    Viktor

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    Interesting! Good to hear you have a workaround for now though :)

    Allan

Sign In or Register to comment.