{"id":468,"date":"2021-12-02T13:30:52","date_gmt":"2021-12-02T13:30:52","guid":{"rendered":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/?p=468"},"modified":"2021-12-02T13:30:52","modified_gmt":"2021-12-02T13:30:52","slug":"using-insert-id","status":"publish","type":"post","link":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/2021\/12\/02\/using-insert-id\/","title":{"rendered":"Using insert ID"},"content":{"rendered":"\n<p>It\u2019s very common to insert data in multiple tables: a book followed by its author, a customer followed by their purchase, and so on. When doing this with an autoincrement column, you will need to retain the insert ID returned for storing in the related table.<br>For example, let\u2019s assume that these devices can be \u201csold\u201d to a person. New device is stored in the device table, we also want to create a key to tie it to the device to a owner. The code to do this is similar to that in, except that the returned insert ID is stored in the variable $insertID and is then used as part of the subsequent query<\/p>\n\n\n\n<p>Now the cat is connected to its \u201cowner\u201d through the devices unique ID, which was created automatically by AUTO_INCREMENT.<\/p>\n\n\n\n<p><a href=\"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/data\/insert_id.txt\">Example for insert<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It\u2019s very common to insert data in multiple tables: a book followed by its author, a customer followed by their purchase, and so on. When doing this with an autoincrement column, you will need to retain the insert ID returned for storing in the related table.For example, let\u2019s assume that these devices can be \u201csold\u201d &hellip; <a href=\"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/2021\/12\/02\/using-insert-id\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using insert ID<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"collection":[{"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=468"}],"version-history":[{"count":1,"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/468\/revisions"}],"predecessor-version":[{"id":469,"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/468\/revisions\/469"}],"wp:attachment":[{"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=468"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/tietokanta.dy.fi:8243\/mikko\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}