{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8558","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8558/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8558/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8558/events","html_url":"https://github.com/yiisoft/yii2/issues/8558","id":80952903,"number":8558,"title":"Sphinx order by RAND()","user":{"login":"garyrutland","id":3715101,"avatar_url":"https://avatars.githubusercontent.com/u/3715101?v=3","gravatar_id":"","url":"https://api.github.com/users/garyrutland","html_url":"https://github.com/garyrutland","followers_url":"https://api.github.com/users/garyrutland/followers","following_url":"https://api.github.com/users/garyrutland/following{/other_user}","gists_url":"https://api.github.com/users/garyrutland/gists{/gist_id}","starred_url":"https://api.github.com/users/garyrutland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyrutland/subscriptions","organizations_url":"https://api.github.com/users/garyrutland/orgs","repos_url":"https://api.github.com/users/garyrutland/repos","events_url":"https://api.github.com/users/garyrutland/events{/privacy}","received_events_url":"https://api.github.com/users/garyrutland/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-26T13:01:59Z","updated_at":"2015-05-26T13:08:48Z","closed_at":"2015-05-26T13:08:48Z","body":"Hi,\r\n\r\nStill in the process of porting my current application from Yii to Yii 2 and come across (what I think) is a limitation with Sphinx.\r\n\r\nIn Yii 1 I could run the following SphinxQL: SELECT id FROM index_name ORDER BY RAND();\r\n\r\nHowever, in Yii2 it doesn't seem to actually pay attention to the RAND() function.\r\n\r\nI've tried two different approaches.\r\nThis one seems to ignore the RAND() and always returns the same row, if you do queryAll() it returns the same results each time.\r\n$sql =  \"SELECT id FROM index_name ORDER BY RAND()\";\r\n$query = Yii::$app->sphinx->createCommand($sql)->queryOne();\r\n\r\n\r\nAlso, this way through an exception or can't find the column.\r\n$query->select('id')\r\n    ->from('index_name')\r\n    ->orderBy('RAND()') // ->orderBy('RAND')\r\n    ->limit(10);\r\n\r\nIs there support for this? Or am I going at this wrong?\r\n\r\nThanks,\r\nGary"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/105520234","html_url":"https://github.com/yiisoft/yii2/issues/8558#issuecomment-105520234","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/8558","id":105520234,"user":{"login":"klimov-paul","id":1482054,"avatar_url":"https://avatars.githubusercontent.com/u/1482054?v=3","gravatar_id":"","url":"https://api.github.com/users/klimov-paul","html_url":"https://github.com/klimov-paul","followers_url":"https://api.github.com/users/klimov-paul/followers","following_url":"https://api.github.com/users/klimov-paul/following{/other_user}","gists_url":"https://api.github.com/users/klimov-paul/gists{/gist_id}","starred_url":"https://api.github.com/users/klimov-paul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klimov-paul/subscriptions","organizations_url":"https://api.github.com/users/klimov-paul/orgs","repos_url":"https://api.github.com/users/klimov-paul/repos","events_url":"https://api.github.com/users/klimov-paul/events{/privacy}","received_events_url":"https://api.github.com/users/klimov-paul/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T13:08:48Z","updated_at":"2015-05-26T13:08:48Z","body":"This is the question to the Sphinx Search Engine project. It does not related to Yii."}}