IBM DB2 Connection

I have to create an application in Yii that runs on an ibm db2 database. I had seen on posts in various places online that this was possible… but after trying with no success, I looked at the source of CDbConnection and see that there is no ibm or db2 drivers in the driver map (shown below).




public $driverMap=array(

   'pgsql'=>'CPgsqlSchema',    // PostgreSQL

   'mysqli'=>'CMysqlSchema',   // MySQL

   'mysql'=>'CMysqlSchema',    // MySQL

   'sqlite'=>'CSqliteSchema',  // sqlite 3

   'sqlite2'=>'CSqliteSchema', // sqlite 2

   'mssql'=>'CMssqlSchema',    // Mssql driver on windows hosts

   'dblib'=>'CMssqlSchema',    // dblib drivers on linux (and maybe others os) hosts

   'sqlsrv'=>'CMssqlSchema',   // Mssql

   'oci'=>'COciSchema',        // Oracle driver

   );



So… how can I get this working? Is there a different way to use the connection string? or perhaps I have the wrong connection string? Anyone know the proper way to do it?

Pretty lost and in need or serious help here. Anything is appreciated. Thank you all.

You have to write a schema yourself, but you might be in luck, because pdo-odbc has a db2 mode:

http://www.php.net/manual/en/ref.pdo-odbc.php

This topic will help:

http://www.yiiframework.com/forum/index.php?/topic/19346-sql-limit-clause/page__st__20__p__94944__hl__odbc__fromsearch__1#entry94944

Yes, I had seen a lot of these posts before. I’ll have to give it all a swing. Is there any why this will allow for AR to be used?

I really had hoped there would be a connection string I could copy/paste or a working solution already in place… but this will give me a chance to dig deeper now. I’ll post my findings and anyone with some information to offer, it would be appreciated greatly.

Thanks. :D

I guess it’s because AR uses a db schema which is using PDO, so things are going to work if your database has a PDO driver.

Let’s hope that pdo-odbc in db2 mode cuts it. :)

I am hoping SOMETHING cuts it. There is a PDO_IBM driver for DB2 as well… may be a better option actually. I have another topic started to cover the creation of a DB2 schema - I’m working on it now. :)

This one uses PDO_IBM:

My extension for IBM DB2:

YiiDB2

Sorry respond after all this time but it takes a lot of support for this extension YiiDB2 to run on ubuntu without the ODBC. Can you help me?

I’ve added a patch to support odbc by overriding driverName property of CDbConnection. It has been marked for 1.1.15.

Yii cloned with its modification and started using it.

Still the same error.

I believe I’m setting something wrong.


'db'=>array(

	//'connectionString' => 'ibm:DRIVER={DB2 ODBC DRIVER};DATABASE=analise_two;HOSTNAME=localhost;PORT=port;PROTOCOL=TCPIP;',

	//'connectionString' => 'ibm:driver=FreeTDS;hostname=localhost;database=sample',

	'connectionString' => 'ibm:DRIVER=ODBC;DATABASE=DATABASETEST;HOSTNAME=localhost;',

	'emulatePrepare' => true,

	'username' => 'root',

	'password' => 'pass',

	'charset' => 'utf8',

	'enableProfiling' => true, //Log SQLs

	'enableParamLogging' => true,//Log SQLs,

	//'class' => 'ext.yiidb2.CIbmDB2Connection'

	'class' => 'CDbConnection'

),

Download and install my extension: YiiDB2

Use yiidb2-beta6.zip for PHP pdo_ibm;

Use yiidb2-ibm_db2-beta4.zip for PHP ibm_db2;

Set up as an example of the page.

For ibm_db2, use in connectionString the prefix "ibm:"

@nineinchnick, thanks!! :)

Own, Thank you man!! :D

Hello to all.

I have a project on a linux machine with 6GB of RAM.

I believe this is an error connection failure caused by trying to access the DB2 database that is in VirtualBox with Linux with 2GB of RAM.


CDbException


CDbConnection failed to open the DB connection: [IBM][CLI Driver] SQL10007N Message "0" could not be retrieved. Reason code: "3". SQLCODE=-1390

I have not found a solution.

Meanwhile I was implementing the project within the same VM.