Jump to content
rwhite35

ZendFramework 2 PDO_IBM Driver Issue

Recommended Posts

Have a Zend Framework 2.4 connection factory that needs to establish a connection with an AS400 iSeries database. The connection has to be made this way bcuz there are multiple test environment and the factory needs to accommodate each.

The method is using Zend\Db\Adapter\Adapter and I pass that class an array of database connection parameters.

At issue: Zend\Db\Adapter doesn't accept the relational database (directory) name. I'm assuming that since the driver is PDO_IBM, there would be some expectation of a field for explicitly defining the name for the directory.

Here is the method:

public function conn($dbs) {
   $this->adapter = new Adapter(array(
       'driver' => $dbs['db']['driver'],
       'dbname' => $dbs['db']['dbname'],
       'username' => $dbs['db']['username'],
       'password' => $dbs['db']['password'],
       'hostname' => $dbs['db']['hostname'],
       'port' => $dbs['db']['port'],
   ));
   var_dump($this->adapter);
   return $this->adapter;
}

Adapter is an alias for \Zend\Db\Adapter\Adapter
And here is the object that gets created.

["driver":protected]=> object(Zend\Db\Adapter\Driver\Pdo\Pdo)#224 (4){ 
  ["connection":protected]=>object(Zend\Db\Adapter\Driver\Pdo\Connection)#225 (6) { 
["driver":protected]=> *RECURSION* 
["profiler":protected]=> NULL 
["driverName":protected]=> string(3)"ibm" 
["connectionParameters":protected]=> array(6) { 
    ["driver"]=> string(7) "PDO_IBM" 
    ["dbname"]=> string(7) “<relational_database_name>” 
    ["username"]=> string(3) “<user_name" 
    ["password"]=> string(3) “<password>" 
    ["hostname"]=> string(9) "127.0.0.1" 
    ["port"]=> string(3) "446" 
}

I can instantiate the connection object using and query the database fine with:

$conn = new \Zend\Db\Adapter\Adapter( ); // using Pdo=ibm:<relational_database_name>

And here is the error

Connect Error: SQLSTATE=42705, SQLConnect: -950 Relational database dbname=<rdn>;hos not in relational database directory.

Any thought (about this topic) are greatly appreciated.  

Regards,

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.