Yiidb2 - Db2_Bind_Param

Hi All,

I’ve been using the YiiDB2 extension (http://www.yiiframework.com/extension/yiidb2/) while testing out the framework on a project I’m working on.

I’ve noticed an issue (which I think is with the extension), where I’m unable to update rows in a table using the ibm_db2 driver. Attempting to follow the ‘Getting Started: Creating Your First Application’, I’ve created installed the DB2 extension as per the extension instructions, and I’ve created the model, controller and views using the Gii generator. This lets me add users, view users and remove them, but not update them.

I get the following issue when trying to update a record (a user in this case):




PHP warning

db2_bind_param(): Describe Param Failed

/data/mgnt/www/protected/extensions/yiidb2/CIbmDB2PdoStatement.php(73)


73         if (!db2_bind_param($this->_stmt, $numColumn, "variable", DB2_PARAM_IN, $type)) {

74             throw new CIbmDB2PdoException(db2_stmt_errormsg());

75         }

76         return true;



I have added the following code in my config/main.php:




		'db' => array(

      			'connectionString' => 'ibm:DRIVER={IBM DB2 ODBC DRIVER};DATABASE=testdb;HOSTNAME=mydbserver.example.com;PORT=60000;PROTOCOL=TCPIP;',

			'username' => 'dbuser',

      			'password' => 'passw0rd',

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

    			),




I have also added the following to the import section of my config/main.php (not sure if this is needed?):




	'import'=>array(

		'application.models.*',

		'application.components.*',

		'ext.yiidb2.*',

	),




I’ve used the yiidb2-ibm_db2-beta3.zip from the extension page. Downloaded and extracted it to /protected/extensions and renamed the folder to yiidb2. I’m running Yii 1.1.13 on PHP 5.4.17, with ibm_db2 configured correctly. DB2 Client version is 9.5.0.

It doesn’t appear to be an error with any of the code I’ve written (because I’ve used the Crud generator for all of it!), so I’m not sure if I’ve mis-configured something, or if this is a bug with the extension.

Hopefully someone can point me in the right direction.

Thanks in advance!

Rob.

I’m checking the error that occurs.

Could you pass me the table structure and type of columns.

And no need to put the ‘import’, because ‘CIbmDB2Connection’ does.

Thank you and Sorry my English.

Hi Edgard,

Thanks for the quick response!

Here is the structure for the User table:




tbl_user

Key	Name		Data Type	Length

*	ID		BIGINT		8

	USERNAME	VARCHAR		128

	PASSWORD	VARCHAR		128

	EMAIL		VARCHAR		128






CREATE TABLE TESTDB.TBL_USER ( ID BIGINT  NOT NULL  GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1, NO CACHE ) , USERNAME VARCHAR (128)  NOT NULL , PASSWORD VARCHAR (128)  NOT NULL , EMAIL VARCHAR (128)  NOT NULL  , CONSTRAINT CC1376065772209 PRIMARY KEY ( ID)  ) ;



Thanks!

Rob.

Try this: https://github.com/edgardmessias/yiidb2/tree/ibm_db2

Hi Edgard,

The fix you have created works perfectly!

Thanks very much for your quick response, and quick solution.

Regards,

Rob