I am blocked by zendframework/zf2#3726, so I have attempted to step around the problem by implementing Doctrine.
I have completed the Doctrine 2 tutorial to replace Zend\Db calls in the Album example. I did this using MySQL on a Windows workstation. Everything works - all good.
Next step - repeat on the IBMi.
It does not work.
Following is the configuration extract from /config/autoload/local.php
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\IBMDB2\DB2Driver',
'params' => array(
'host' => 'dse',
'port' => '50000',
'user' => '***',
'password' => '***',
'dbname' => '*LOCAL',
),
I can connect to DB2 by calling 'db2_connect' with the information above.
Note the driver definition. I found this in /vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php
But a call to $this->getEntityManager()->getRepository(...)->findAll();
results in the following exception;
PDOException
File:
/www/local/zf2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:36
Message:
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Stack trace:
#0 /www/local/zf2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(36): PDO->__construct('mysql:host=loca...', 'username', 'password', Array)
#1 /www/local/zf2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php(47): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=loca...', 'username', 'password', Array)
#2 /www/local/zf2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(350): Doctrine\DBAL\Driver\PDOMySql\Driver->connect(Array, 'username', 'password', Array)
#3 /www/local/zf2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(627): Doctrine\DBAL\Connection->connect()
#4 /www/local/zf2/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php(844): Doctrine\DBAL\Connection->executeQuery('SELECT t0.CUR A...', Array, Array)
#5 /www/local/zf2/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php(157): Doctrine\ORM\Persisters\BasicEntityPersister->loadAll(Array, NULL, NULL, NULL)
#6 /www/local/zf2/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php(141): Doctrine\ORM\EntityRepository->findBy(Array)
#7 /www/local/zf2/module/Application/src/Application/Controller/IndexController.php(69): Doctrine\ORM\EntityRepository->findAll()
There is no reference in the (my) code on the IBMi to a MySQL server, yet the error clearly states a failure to connect to MySQL.
Has anyone had any success connecting to IBMi DB2 using Doctrine or Zend/Db on ZF2?