{"action":"created","issue":{"url":"https://api.github.com/repos/delight-im/PHP-DB/issues/4","repository_url":"https://api.github.com/repos/delight-im/PHP-DB","labels_url":"https://api.github.com/repos/delight-im/PHP-DB/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/delight-im/PHP-DB/issues/4/comments","events_url":"https://api.github.com/repos/delight-im/PHP-DB/issues/4/events","html_url":"https://github.com/delight-im/PHP-DB/pull/4","id":304984106,"number":4,"title":"Added insert on duplicate function","user":{"login":"goodProjects","id":28712999,"avatar_url":"https://avatars3.githubusercontent.com/u/28712999?v=4","gravatar_id":"","url":"https://api.github.com/users/goodProjects","html_url":"https://github.com/goodProjects","followers_url":"https://api.github.com/users/goodProjects/followers","following_url":"https://api.github.com/users/goodProjects/following{/other_user}","gists_url":"https://api.github.com/users/goodProjects/gists{/gist_id}","starred_url":"https://api.github.com/users/goodProjects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goodProjects/subscriptions","organizations_url":"https://api.github.com/users/goodProjects/orgs","repos_url":"https://api.github.com/users/goodProjects/repos","events_url":"https://api.github.com/users/goodProjects/events{/privacy}","received_events_url":"https://api.github.com/users/goodProjects/received_events","type":"User","site_admin":false},"labels":[{"id":438937053,"url":"https://api.github.com/repos/delight-im/PHP-DB/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-14T00:39:16Z","updated_at":"2018-03-14T14:48:22Z","closed_at":"2018-03-14T14:48:22Z","author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/delight-im/PHP-DB/pulls/4","html_url":"https://github.com/delight-im/PHP-DB/pull/4","diff_url":"https://github.com/delight-im/PHP-DB/pull/4.diff","patch_url":"https://github.com/delight-im/PHP-DB/pull/4.patch"},"body":""},"comment":{"url":"https://api.github.com/repos/delight-im/PHP-DB/issues/comments/373047885","html_url":"https://github.com/delight-im/PHP-DB/pull/4#issuecomment-373047885","issue_url":"https://api.github.com/repos/delight-im/PHP-DB/issues/4","id":373047885,"user":{"login":"ocram","id":1681478,"avatar_url":"https://avatars0.githubusercontent.com/u/1681478?v=4","gravatar_id":"","url":"https://api.github.com/users/ocram","html_url":"https://github.com/ocram","followers_url":"https://api.github.com/users/ocram/followers","following_url":"https://api.github.com/users/ocram/following{/other_user}","gists_url":"https://api.github.com/users/ocram/gists{/gist_id}","starred_url":"https://api.github.com/users/ocram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocram/subscriptions","organizations_url":"https://api.github.com/users/ocram/orgs","repos_url":"https://api.github.com/users/ocram/repos","events_url":"https://api.github.com/users/ocram/events{/privacy}","received_events_url":"https://api.github.com/users/ocram/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T14:48:22Z","updated_at":"2018-03-14T14:48:22Z","author_association":"CONTRIBUTOR","body":"Thank you!\r\n\r\nWe’d love to have this, but unfortunately, the “upsert” feature is much more difficult to implement. A main goal of this library, using PDO, is portability. The suggested solution is not portable, though, as it works with MySQL only.\r\n\r\nMySQL [[1]](https://dev.mysql.com/doc/refman/5.5/en/insert.html) [[2]](https://dev.mysql.com/doc/refman/5.5/en/insert-on-duplicate.html):\r\n\r\n```sql\r\nINSERT INTO ... VALUES ... ON DUPLICATE KEY UPDATE ...\r\n-- or\r\nINSERT IGNORE INTO ... VALUES ...\r\n```\r\n\r\n[PostgreSQL 9.5+](https://www.postgresql.org/docs/9.5/static/sql-insert.html):\r\n\r\n```sql\r\nINSERT INTO ... VALUES ... ON CONFLICT (...) DO UPDATE SET ...\r\n-- or\r\nINSERT INTO ... VALUES ... ON CONFLICT (...) DO NOTHING\r\n```\r\n\r\n[SQLite](https://www.sqlite.org/lang_conflict.html):\r\n\r\n```sql\r\nINSERT OR REPLACE INTO ... VALUES ...\r\nINSERT OR IGNORE INTO ... VALUES ...\r\n```\r\n\r\nHowever, the approaches above are not really equivalent. So it might still be easier to emulate the “upsert” using a select and an insert or an update.\r\n\r\nEven looking just at MySQL, the syntax is much more powerful and can do a lot more than just updating a single column to a new literal.\r\n\r\nAll that being said, while it would be great to have this feature, it is difficult to implement for a general-purpose library. For a specific project, one’s custom solution may work fine."}}
{"actor":{"display_login":"ocram"}}