{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/9859","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/9859/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/9859/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/9859/events","html_url":"https://github.com/yiisoft/yii2/pull/9859","id":110451014,"number":9859,"title":"Implemented basic connection interface.","user":{"login":"SamMousa","id":547021,"avatar_url":"https://avatars.githubusercontent.com/u/547021?v=3","gravatar_id":"","url":"https://api.github.com/users/SamMousa","html_url":"https://github.com/SamMousa","followers_url":"https://api.github.com/users/SamMousa/followers","following_url":"https://api.github.com/users/SamMousa/following{/other_user}","gists_url":"https://api.github.com/users/SamMousa/gists{/gist_id}","starred_url":"https://api.github.com/users/SamMousa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamMousa/subscriptions","organizations_url":"https://api.github.com/users/SamMousa/orgs","repos_url":"https://api.github.com/users/SamMousa/repos","events_url":"https://api.github.com/users/SamMousa/events{/privacy}","received_events_url":"https://api.github.com/users/SamMousa/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/feature:db","name":"feature:db","color":"bfd4f2"},{"url":"https://api.github.com/repos/yiisoft/yii2/labels/type:enhancement","name":"type:enhancement","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-08T13:28:39Z","updated_at":"2015-11-20T10:22:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/yiisoft/yii2/pulls/9859","html_url":"https://github.com/yiisoft/yii2/pull/9859","diff_url":"https://github.com/yiisoft/yii2/pull/9859.diff","patch_url":"https://github.com/yiisoft/yii2/pull/9859.patch"},"body":"This is a first implementation of the ConnectionInterface from #9743.\r\n\r\nNote that all public function of the Connection class are in the interface, with the exception of getLastInsertID which is used no where in the code as far as I can tell.\r\n\r\nThere are currently a number of public properties that are directly used by other classes, these should be changed to getters / setters and added to the interface.\r\n\r\nAlso this interface should at some point be split up into a more basic interface and several more advanced interfaces.\r\nSome interfaces that come to mind:\r\n- ConnectionInterface --> basic connection \r\n- TransactionConnectionInterface --> implemented by connections that (maybe) support transactions, note the maybe here is because a Connection class might support different drivers that may support transactions.\r\n- CacheableInterface --> This could be even broader than just connection. Basically any class could have a cache function that is defined as:\r\n\r\n        public function cache(Closure $closure, $timeout) {\r\n            // Do pre-caching stuff..\r\n            $closure($this);\r\n            // Do post-caching stuff.\r\n        }\r\n- PooledConnectionInterface --> implemented by connections that support pooling.\r\n\r\n\r\nAll these interfaces do not break BC but do add some cleanliness to the code. In general type hinting should be aimed more at interfaces and less at classes.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/158349597","html_url":"https://github.com/yiisoft/yii2/pull/9859#issuecomment-158349597","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/9859","id":158349597,"user":{"login":"SamMousa","id":547021,"avatar_url":"https://avatars.githubusercontent.com/u/547021?v=3","gravatar_id":"","url":"https://api.github.com/users/SamMousa","html_url":"https://github.com/SamMousa","followers_url":"https://api.github.com/users/SamMousa/followers","following_url":"https://api.github.com/users/SamMousa/following{/other_user}","gists_url":"https://api.github.com/users/SamMousa/gists{/gist_id}","starred_url":"https://api.github.com/users/SamMousa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamMousa/subscriptions","organizations_url":"https://api.github.com/users/SamMousa/orgs","repos_url":"https://api.github.com/users/SamMousa/repos","events_url":"https://api.github.com/users/SamMousa/events{/privacy}","received_events_url":"https://api.github.com/users/SamMousa/received_events","type":"User","site_admin":false},"created_at":"2015-11-20T10:22:39Z","updated_at":"2015-11-20T10:22:39Z","body":"Note, `getSlavePdo` and `getMasterPdo` are actually wrappers for `getSlave()->pdo` and `getMaster()->pdo`, so these can be removed from the interface and connection implementation and instead be used by the (pdo specific) `Command` object directly.\r\n\r\n-- getSlave and getMaster return a new `Connection` of the same type so this is generic.\r\n\r\n`setDriverName()` is not used explicitly anywhere, which means it is probably just part of configuration. Instead it could be a protected property and it could be lowercased in the `init()` function (lowercasing is all the function does. This would also disable the changing of driver name after construction which makes sense.\r\n"}}