{"action":"closed","issue":{"url":"https://api.github.com/repos/catfan/Medoo/issues/726","repository_url":"https://api.github.com/repos/catfan/Medoo","labels_url":"https://api.github.com/repos/catfan/Medoo/issues/726/labels{/name}","comments_url":"https://api.github.com/repos/catfan/Medoo/issues/726/comments","events_url":"https://api.github.com/repos/catfan/Medoo/issues/726/events","html_url":"https://github.com/catfan/Medoo/issues/726","id":303286879,"number":726,"title":"Can't use Medoo::raw(\"WHERE ...\") in db->count($table, $where) $where arg","user":{"login":"pedrofsantoscom","id":2325978,"avatar_url":"https://avatars1.githubusercontent.com/u/2325978?v=4","gravatar_id":"","url":"https://api.github.com/users/pedrofsantoscom","html_url":"https://github.com/pedrofsantoscom","followers_url":"https://api.github.com/users/pedrofsantoscom/followers","following_url":"https://api.github.com/users/pedrofsantoscom/following{/other_user}","gists_url":"https://api.github.com/users/pedrofsantoscom/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrofsantoscom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrofsantoscom/subscriptions","organizations_url":"https://api.github.com/users/pedrofsantoscom/orgs","repos_url":"https://api.github.com/users/pedrofsantoscom/repos","events_url":"https://api.github.com/users/pedrofsantoscom/events{/privacy}","received_events_url":"https://api.github.com/users/pedrofsantoscom/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-07T22:39:15Z","updated_at":"2018-03-23T19:08:51Z","closed_at":"2018-03-23T19:08:51Z","author_association":"NONE","body":"Hi there,\r\n\r\nI'm trying to do a complex sql where clause, so i'm using the `Medoo::raw()`.\r\nThe issue is in with the `$where` argument for the `$db->count()` function, it just doesn't build the where clause:\r\n```php\r\n$result = $db->debug()->count(\r\n                $this->table,\r\n                Medoo::raw(\r\n                    \"WHERE\r\n                    <user> = :user\r\n                    AND\r\n                    (\r\n                        (\r\n                            YEARWEEK(<date>) = YEARWEEK( CURDATE() )\r\n                            AND DAYOFWEEK(<date>) = 1\r\n                        )\r\n                        OR\r\n                        (\r\n                            YEARWEEK(<date>) = YEARWEEK( CURDATE() ) + 1\r\n                            AND DAYOFWEEK(<date>) = 1\r\n                        )\r\n                    )\", [\":user\" => $user]));\r\n```\r\nCount debug output:\r\n```sql\r\nSELECT COUNT() FROM `table_name`\r\n```\r\n\r\nBut using `$db->select()` it does indeed build the raw sql:\r\n```php\r\n$result = $db->debug()->select(\r\n                $this->table,\r\n                [\"count\" => Medoo::raw(\"COUNT()\")],\r\n                Medoo::raw(\r\n                    \"WHERE\r\n                    <user> = :user\r\n                    AND\r\n                    (\r\n                        (\r\n                            YEARWEEK(<date>) = YEARWEEK( CURDATE() )\r\n                            AND DAYOFWEEK(<date>) = 1\r\n                        )\r\n                        OR\r\n                        (\r\n                            YEARWEEK(<date>) = YEARWEEK( CURDATE() ) + 1\r\n                            AND DAYOFWEEK(<date>) = 1\r\n                        )\r\n                    )\", [\":user\" => $user]));\r\n```\r\nSelect debug output:\r\n```sql\r\nSELECT COUNT(*) AS `count` FROM `table_name` WHERE `user` = 'user1' AND ( ( YEARWEEK(`date`) = YEARWEEK( CURDATE() ) AND DAYOFWEEK(`date`) = 1 ) OR ( YEARWEEK(`date`) = YEARWEEK( CURDATE() ) + 1 AND DAYOFWEEK(`date`) = 1 ) )\r\n```\r\n\r\nIs this the supposed behaviour? Would be awesome if the Medoo aggregate functions would build the raw sql"}}
{"actor":{"display_login":"pedrofsantoscom"}}