sybasezend-framework3

how do I connect Sybase to zendframework 3?


I can't connect Sybase to zf3. but I can connect core PHP.

$Appname = basename($_SERVER['SCRIPT_FILENAME'], ".php");
    $Dsquery = getenv("DSQUERY");
    $Dbname = "tempdb";
    $Username = "sa";
    $Passwd = "xxxxxxxx";

$conn = sybase_connect($Dsquery, $Username, $Passwd);

It was able to connect with core PHP and Sybase.

Let me know how to connect with ZF3 below.

return [
    'doctrine' => [
        'connection' => [
            'orm_default' => [
                'driverClass' => PDOMySqlDriver::class,
                'params' => [
                    'host'     => 'localhost',                    
                    'user'     => 'root',
                    'password' => '1234',
                    'dbname'   => 'test_db',
                ]
            ],            
        ],        
    ],
    'db' => [
        'driver' => 'Mysqli',
        'database' => 'test_db',
        'username' => 'root',
        'password' => '1234',
    ],
];

Solution

  • 1.We have installed Devart to make a PDO odbc connection with Sybase.

    2.Need to create Devart Driver in System DSN in ODBC Datasource administrator

    3.Then in zend3 we used pdo connection with devart odbc.

    4.To achive doctrine, we passed connection Object to doctrine parameters.

    <?php
    use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySqlDriver;
    $connPdo = null;
    
    try {
        $connPdo = new PDO("odbc:DRIVER={Devart ODBC Driver for ASE};host=Develop;dbname=poc;charset=utf8", "sa", "");
        $connPdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
    } catch (PDOException $e) {
        echo $e->getMessage() . '</br>';
    }
    return [
        'doctrine' => [
            'connection' => [
                'orm_default' => [
                    'driverClass' => PDOMySqlDriver::class,
                    'params' => [
                        'pdo' => $connPdo
                    ]
                ],            
            ],        
        ],
    ];