Monday, July 29, 2013

Issue with Update function in sql server in CakePHP, not working

Hi,

We have a client in CakePHP running with MYSQL. PHP version is 5.4.16, Apache 2.4.4, latest XAMP.

THis running is working fine. We already have similar Database in MSSQL also. Now client wants to run this client with MSSQL also.

We are using php_pdo_sqlsrv_54_ts.dll and php_sqlsrv_54_ts.dll for MSSQL driver for this. Its sql server 2005.

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

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

Now this works fine in MySql and generated the following Update query
UPDATE `ipa`.`configurationtable` AS `Configurationtable` SET `Configurationtable`.`configuration_optionsetting` = 12 WHERE `Configurationtable`.`configuration_optionname` = 'searchPaginationLimit'

But in MSSQL Server, it fails and generates completely wrong query which is

SELECT [Configurationtable].[id] AS [Configurationtable__id] FROM [configurationtable] AS [Configurationtable] WHERE [Configurationtable].[configuration_optionname] = N'searchPaginationLimit'

Now, If I make Update() function in \lib\Cake\Model\Datasource\Database\Sqlserver.php similar to Update() in \lib\Cake\Model\Datasource\Database\Mysql.php then it works fine. It generates proper correct "Update" query
I could not figure out why is it going so? Is it something I am going wrong OR there is bug in cake?
Any would be of great help.
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: