yii2odbcpervasive

How to connect to a pervasive database with Yii2?


I would like to make a connection to a pervasive database in Yii2. I have tried odbc, as it's installed but when I'm trying to create models with Gii I'm getting the error: Connection does not support reading schema information for 'pervasive odbc interface' DBMS.

Could you please point me to the right direction? Thank you.


Solution

  • I had to enable odbc and pdo_odbc in PHP (WAMP). This is my db.php:

    return [
        'class' => 'yii\db\Connection',
        'driverName' => 'Pervasive ODBC Interface',
        'dsn' => 'odbc:Driver={Pervasive ODBC Interface};ServerName=localhost;ServerDSN=MYDB',
        'username' => '',
        'password' => '',
    ];
    

    my controller:

    public function actionIndex() {
        try {
            Yii::$app->db->open();
            echo "Connection successful!";
        } catch (\Exception $e) {
            echo "Connection failed: " . $e->getMessage();
        }
    }
    

    so it's basically working, but unfortunately not supported by Gii.