{"action":"created","issue":{"url":"https://api.github.com/repos/joshcam/PHP-MySQLi-Database-Class/issues/152","labels_url":"https://api.github.com/repos/joshcam/PHP-MySQLi-Database-Class/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/joshcam/PHP-MySQLi-Database-Class/issues/152/comments","events_url":"https://api.github.com/repos/joshcam/PHP-MySQLi-Database-Class/issues/152/events","html_url":"https://github.com/joshcam/PHP-MySQLi-Database-Class/issues/152","id":45196624,"number":152,"title":"UPDATE with CASE, WHEN and THEN","user":{"login":"smithfoto","id":7828470,"avatar_url":"https://avatars.githubusercontent.com/u/7828470?v=3","gravatar_id":"","url":"https://api.github.com/users/smithfoto","html_url":"https://github.com/smithfoto","followers_url":"https://api.github.com/users/smithfoto/followers","following_url":"https://api.github.com/users/smithfoto/following{/other_user}","gists_url":"https://api.github.com/users/smithfoto/gists{/gist_id}","starred_url":"https://api.github.com/users/smithfoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smithfoto/subscriptions","organizations_url":"https://api.github.com/users/smithfoto/orgs","repos_url":"https://api.github.com/users/smithfoto/repos","events_url":"https://api.github.com/users/smithfoto/events{/privacy}","received_events_url":"https://api.github.com/users/smithfoto/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-10-08T02:40:02Z","updated_at":"2015-08-06T08:09:20Z","closed_at":"2015-08-06T08:09:20Z","body":"foreach ($data as $key => $val) {\r\n   $str.= \" WHEN $key THEN $val \";\r\n   $ids[] = $key;\r\n}\r\n$keys = implode(\",\", $ids);\r\n\r\n// rawQuery WORK\r\n   $q = \"UPDATE \r\n                 ct_content_category\r\n            SET\r\n                ordering = CASE id {$str} ELSE ordering END\r\n            WHERE\r\n               id IN($keys)\r\n\t    \";\r\n   $db->rawQuery($q);\r\n\r\n========================================\r\n// update NOT WORK\r\n$data = Array(\r\n                      'ordering ' => \"CASE id {$str} ELSE ordering END\"\r\n             );\r\n   $db->where('id', $keys, 'IN');\r\n   $db->update('content_category', $data);\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/joshcam/PHP-MySQLi-Database-Class/issues/comments/128285627","html_url":"https://github.com/joshcam/PHP-MySQLi-Database-Class/issues/152#issuecomment-128285627","issue_url":"https://api.github.com/repos/joshcam/PHP-MySQLi-Database-Class/issues/152","id":128285627,"user":{"login":"avbdr","id":3286514,"avatar_url":"https://avatars.githubusercontent.com/u/3286514?v=3","gravatar_id":"","url":"https://api.github.com/users/avbdr","html_url":"https://github.com/avbdr","followers_url":"https://api.github.com/users/avbdr/followers","following_url":"https://api.github.com/users/avbdr/following{/other_user}","gists_url":"https://api.github.com/users/avbdr/gists{/gist_id}","starred_url":"https://api.github.com/users/avbdr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avbdr/subscriptions","organizations_url":"https://api.github.com/users/avbdr/orgs","repos_url":"https://api.github.com/users/avbdr/repos","events_url":"https://api.github.com/users/avbdr/events{/privacy}","received_events_url":"https://api.github.com/users/avbdr/received_events","type":"User","site_admin":false},"created_at":"2015-08-06T08:09:20Z","updated_at":"2015-08-06T08:09:20Z","body":"this should work with $db->func() now."}}