{"action":"created","issue":{"url":"https://api.github.com/repos/jfruitet/moodle_referentiel_m27/issues/2","repository_url":"https://api.github.com/repos/jfruitet/moodle_referentiel_m27","labels_url":"https://api.github.com/repos/jfruitet/moodle_referentiel_m27/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/jfruitet/moodle_referentiel_m27/issues/2/comments","events_url":"https://api.github.com/repos/jfruitet/moodle_referentiel_m27/issues/2/events","html_url":"https://github.com/jfruitet/moodle_referentiel_m27/issues/2","id":139837126,"number":2,"title":"Exception thrwon into admin > reports > Skill repository","user":{"login":"gabrielrosset","id":16338923,"avatar_url":"https://avatars.githubusercontent.com/u/16338923?v=3","gravatar_id":"","url":"https://api.github.com/users/gabrielrosset","html_url":"https://github.com/gabrielrosset","followers_url":"https://api.github.com/users/gabrielrosset/followers","following_url":"https://api.github.com/users/gabrielrosset/following{/other_user}","gists_url":"https://api.github.com/users/gabrielrosset/gists{/gist_id}","starred_url":"https://api.github.com/users/gabrielrosset/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabrielrosset/subscriptions","organizations_url":"https://api.github.com/users/gabrielrosset/orgs","repos_url":"https://api.github.com/users/gabrielrosset/repos","events_url":"https://api.github.com/users/gabrielrosset/events{/privacy}","received_events_url":"https://api.github.com/users/gabrielrosset/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-03-10T09:47:35Z","updated_at":"2016-03-11T08:44:23Z","closed_at":null,"body":"Hi Jean,\r\n    I just saw another bug concerning some DBMS like SQLServer which does not allow to specify fields in \"ORDER BY\" clause while they're not in \"SELECT\" clause.\r\n\r\nTo reproduce : \r\njust go to admin menu and click into \"reports > Skill repository\"\r\n\r\nHere is the detail : \r\n\r\nDebug info: SQLState: 42000<br>\r\nError Code: 145<br>\r\nMessage: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Les éléments ORDER BY doivent se retrouver dans la liste de sélection si SELECT DISTINCT est spécifié.<br>\r\n\r\nSELECT DISTINCT userid FROM mdl_referentiel_activite WHERE ref_instance='1' ORDER BY userid ASC, date_creation DESC\r\n[array (\r\n0 => '1',\r\n)]\r\nError code: dmlreadexception\r\nStack trace:\r\n    line 443 of \\lib\\dml\\moodle_database.php: dml_read_exception thrown\r\n    line 291 of \\lib\\dml\\sqlsrv_native_moodle_database.php: call to moodle_database->query_end()\r\n    line 398 of \\lib\\dml\\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->query_end()\r\n    line 850 of \\lib\\dml\\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->do_query()\r\n    line 898 of \\lib\\dml\\sqlsrv_native_moodle_database.php: call to sqlsrv_native_moodle_database->get_recordset_sql()\r\n    line 1084 of \\mod\\referentiel\\locallib.php: call to sqlsrv_native_moodle_database->get_records_sql()\r\n    line 169 of \\report\\referentiel\\index.php: call to referentiel_get_users_activites_instance()"},"comment":{"url":"https://api.github.com/repos/jfruitet/moodle_referentiel_m27/issues/comments/195260190","html_url":"https://github.com/jfruitet/moodle_referentiel_m27/issues/2#issuecomment-195260190","issue_url":"https://api.github.com/repos/jfruitet/moodle_referentiel_m27/issues/2","id":195260190,"user":{"login":"jfruitet","id":1632466,"avatar_url":"https://avatars.githubusercontent.com/u/1632466?v=3","gravatar_id":"","url":"https://api.github.com/users/jfruitet","html_url":"https://github.com/jfruitet","followers_url":"https://api.github.com/users/jfruitet/followers","following_url":"https://api.github.com/users/jfruitet/following{/other_user}","gists_url":"https://api.github.com/users/jfruitet/gists{/gist_id}","starred_url":"https://api.github.com/users/jfruitet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfruitet/subscriptions","organizations_url":"https://api.github.com/users/jfruitet/orgs","repos_url":"https://api.github.com/users/jfruitet/repos","events_url":"https://api.github.com/users/jfruitet/events{/privacy}","received_events_url":"https://api.github.com/users/jfruitet/received_events","type":"User","site_admin":false},"created_at":"2016-03-11T08:44:23Z","updated_at":"2016-03-11T08:44:23Z","body":"This function has not to be so sophisticated!\r\n I have made a radical correction:\r\n\r\nfunction referentiel_get_users_activites_instance($referentiel_instance_id)\r\n{ global $DB; \t\r\nif (!empty($referentiel_instance_id)){\r\n        $params = array(\"refid\" => \"$referentiel_instance_id\");\r\n        $sql=\"SELECT DISTINCT userid FROM {referentiel_activite} WHERE ref_instance=:refid GROUP BY userid ORDER BY userid \";\r\n\t\t\r\nif ($recs = $DB->get_records_sql($sql, $params)){\r\n\t\t\treturn ($recs);\r\n\t\t}\r\n\t}\r\n    \r\nreturn NULL;\r\n}\r\n\r\n\r\n\r\n\r\n\r\n"}}