I am trying to update table, but first check if record exits in table in Zend framework.
I am trying to achieve the same using insert on DUPLICATE KEY UPDATE syntax.
Below is my actual update query.
$updatetokenquery = "UPDATE `UsersNew`, `UsersOptStatus` SET UsersOptStatus.Uid ='".$uid."', UsersOptStatus.CreatedDate=now(), UsersOptStatus.Action_key='".$actionkey."', UsersNew.DeviceToken='".$newdtoken."',"
. "UsersNew.DeviceInfo='".serialize($data['DeviceInfo'])."' , UsersNew.DeviceType='".strtolower($data['DeviceInfo']['OS'])."'"
. "WHERE UsersNew.HashedUid ='".$newUserId."' ";
I am trying to check if record exists, then update else im inserting.
Below is the way i am trying.
$Inserttokenquery = "INSERT INTO UsersOptStatus (Id, Uid, CreatedDate,Action_key) VALUES (1,'$uid',now(),'$actionkey')
ON DUPLICATE KEY UPDATE `UsersNew`, `UsersOptStatus` SET UsersOptStatus.Uid ='".$uid."', UsersOptStatus.CreatedDate=now(), UsersOptStatus.Action_key='".$actionkey."', UsersNew.DeviceToken='".$newdtoken."',"
. "UsersNew.DeviceInfo='".serialize($data['DeviceInfo'])."' , UsersNew.DeviceType='".strtolower($data['DeviceInfo']['OS'])."'"
. "WHERE UsersNew.HashedUid ='".$newUserId."'";
I am getting the below error:
check the manual that corresponds to your MySQL server version for the right syntax to use near \u0027
UsersOptStatus
SET UsersOptStatus.Uid =\u00271608\u0027, UsersOptStatus.
Tried removing the SET keyword from this post, but no helping.