0

zend framework 1.x

how to receive zend db_adapter and connect to mysql having dsn like

mysql://john:pass@localhost:3306/my_db

previously was always using this way:

$connectParams = array('dbname' => MY_DB,
        'password' => MY_PASS,
        'username' =>  MY_USER,
        'host' => MY_HOST,
        'slave' => array(),
        'maxQueryAllowedTime' => 500,
        'logQueries' => false);

return new \Db_Adapter_Pdo_Mysqlreplicator($connectParams);

sure i can parse dsn and use usual way, just curious if i can use DSN directly, coz PDO can use it but i cant find how to use it through Zend Db_Adapter

Eugene
  • 1,680
  • 3
  • 14
  • 23

1 Answers1

0

If you are using ZendFramework 1.x ->Try this:-

$config = array('dbname' => 'yourDbName',
        'password' => 'yourpassword',
        'username' =>  'root',
        'host' => 'localhost',
        'slave' => array(),
        'maxQueryAllowedTime' => 500,
        'logQueries' => false);
$adapter = new Zend_Db_Adapter_Mysqli($config);
if ($config) {
    echo ' connected';
}
Mubo
  • 1,078
  • 8
  • 16