Monday, July 29, 2013

Issue Update() function in MSSQLfor CakePHP

Hi,

I am new to CakePHP but worked extensively in C++/C/Java etc. I already spend more than a day but could not figure out what is the reason for the following problem.

I am using latest XAMP version with 5.4.16 PHP, Apache 2.4.4. We have developed a small client on CakePHP with MYSQL DB. Its working fine. We already has similar DB in MSSQL. Now we need to run this client with MSSQL.

We are using php_pdo_sqlsrv_54_ts.dll and php_sqlsrv_54_ts.dll for MSSQL driver for this.

Whenever we are updating values in tables, we are using following UpdateAll() of Model.PHP which further calls update() of datasource as

$this->Configurationtable->updateAll(('Configurationtable.configuration_optionsetting' =>  $limit ), array('Configurationtable.configuration_optionname =' => $optionName)))

Where $limit and $optionName has value values. This work work in MYSQL and generates 

UPDATE `dbname`.`configurationtable` AS `Configurationtable` SET `Configurationtable`.`configuration_optionsetting` = 12 WHERE `Configurationtable`.`configuration_optionname` = 'searchPaginationLimit'

But in MSSQL, it fails and generate something completely different like this
SELECT [Configurationtable].[id] AS [Configurationtable__id] FROM [configurationtable] AS [Configurationtable] WHERE [Configurationtable].[configuration_optionname] = N'searchPaginationLimit'

Now, if  I modify the update() function in \Cake\Model\Datasource\Database\Sqlserver.php and make it similar to update() function in \Cake\Model\Datasource\Database\Mysql.php, then it works absolutely fine and generate a proper "Update" Query in MSSQL also?

I could not figure out WHY? Is it something I am doing wrong OR is there a bug in Cake?

Can you please help me.

Cheers

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: