{"id":120,"date":"2015-04-18T06:37:56","date_gmt":"2015-04-18T06:37:56","guid":{"rendered":"http:\/\/jamesdowen.com\/blog\/?p=120"},"modified":"2015-04-18T10:12:14","modified_gmt":"2015-04-18T10:12:14","slug":"finally-getting-round-to-using-idiorm-in-php","status":"publish","type":"post","link":"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/","title":{"rendered":"Finally getting round to using Idiorm in PHP"},"content":{"rendered":"<p>Over recent years, I have been using PDO in PHP to execute queries on database. Why? Because it&#8217;s easy to use and most of all, it&#8217;s secure &#8211; meaning I no longer had to worry about SQL injection.<\/p>\n<p>Some time ago though, I was introduced to <a href=\"https:\/\/github.com\/j4mie\/idiorm\" target=\"_blank\">Idiorm<\/a> by a co-developer on a large project. He hadn&#8217;t used it much himself, but we decided to use it in this instance so I went away and <a href=\"https:\/\/idiorm.readthedocs.org\/en\/latest\/\" target=\"_blank\">read it&#8217;s documentation<\/a>. After using it for a couple of weeks, I have now begun to use it on any new projects I develop from now on.<\/p>\n<h3>Here&#8217;s what I found:<\/h3>\n<ul>\n<li>It&#8217;s even easier<\/li>\n<li>It dramatically speeds up development<\/li>\n<li>It allows the mapping of database column names to working field names<\/li>\n<li>Data access is simple<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3>To show the difference:<\/h3>\n<p>What I might have done <strong>before<\/strong> using Idiorm:<\/p>\n<div class=\"line number1 index0 alt2\">\n<pre class=\"lang:php decode:true\">$sql= \"SELECT filmID, filmName, filmDescription, filmImage, filmPrice, filmReview FROM movies WHERE filmID = :filmID\";\r\n$stmt = $pdo-&gt;prepare($sql);\r\n$stmt-&gt;bindParam(':filmID', \"5\", PDO::PARAM_INT);\r\n$stmt-&gt;execute();<\/pre>\n<p>What I do <strong>now<\/strong> I am using Idiorm:<\/p>\n<pre class=\"\">$movie = ORM::for_table('movies')->find_one(5);<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over recent years, I have been using PDO in PHP to execute queries on database. Why? Because it&#8217;s easy to use and most of all, it&#8217;s secure &#8211; meaning I no longer had to worry about SQL injection. Some time ago though, I was introduced to Idiorm by a co-developer on a large project. He [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[77,75,76,16],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Finally getting round to using Idiorm in PHP | James Dowen<\/title>\n<meta name=\"description\" content=\"Some time ago though, I was introduced to Idiorm by a co-developer on a large project. I&#039;ve finally got round to using it.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Finally getting round to using Idiorm in PHP | James Dowen\" \/>\n<meta property=\"og:description\" content=\"Some time ago though, I was introduced to Idiorm by a co-developer on a large project. I&#039;ve finally got round to using it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/\" \/>\n<meta property=\"og:site_name\" content=\"James Dowen\" \/>\n<meta property=\"article:published_time\" content=\"2015-04-18T06:37:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-04-18T10:12:14+00:00\" \/>\n<meta name=\"author\" content=\"James\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/\",\"url\":\"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/\",\"name\":\"Finally getting round to using Idiorm in PHP | James Dowen\",\"isPartOf\":{\"@id\":\"https:\/\/jamesdowen.com\/blog\/#website\"},\"datePublished\":\"2015-04-18T06:37:56+00:00\",\"dateModified\":\"2015-04-18T10:12:14+00:00\",\"author\":{\"@id\":\"https:\/\/jamesdowen.com\/blog\/#\/schema\/person\/51179280d7d76166490e1c27be360931\"},\"description\":\"Some time ago though, I was introduced to Idiorm by a co-developer on a large project. I've finally got round to using it.\",\"breadcrumb\":{\"@id\":\"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jamesdowen.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Finally getting round to using Idiorm in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jamesdowen.com\/blog\/#website\",\"url\":\"https:\/\/jamesdowen.com\/blog\/\",\"name\":\"James Dowen\",\"description\":\"A blog about web development.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jamesdowen.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/jamesdowen.com\/blog\/#\/schema\/person\/51179280d7d76166490e1c27be360931\",\"name\":\"James\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jamesdowen.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e4d7008d9ebb77f8de729f655e30d11f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e4d7008d9ebb77f8de729f655e30d11f?s=96&d=mm&r=g\",\"caption\":\"James\"},\"sameAs\":[\"http:\/\/jamesdowen.com\"],\"url\":\"https:\/\/jamesdowen.com\/blog\/author\/jdowen\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Finally getting round to using Idiorm in PHP | James Dowen","description":"Some time ago though, I was introduced to Idiorm by a co-developer on a large project. I've finally got round to using it.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/","og_locale":"en_US","og_type":"article","og_title":"Finally getting round to using Idiorm in PHP | James Dowen","og_description":"Some time ago though, I was introduced to Idiorm by a co-developer on a large project. I've finally got round to using it.","og_url":"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/","og_site_name":"James Dowen","article_published_time":"2015-04-18T06:37:56+00:00","article_modified_time":"2015-04-18T10:12:14+00:00","author":"James","twitter_misc":{"Written by":"James","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/","url":"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/","name":"Finally getting round to using Idiorm in PHP | James Dowen","isPartOf":{"@id":"https:\/\/jamesdowen.com\/blog\/#website"},"datePublished":"2015-04-18T06:37:56+00:00","dateModified":"2015-04-18T10:12:14+00:00","author":{"@id":"https:\/\/jamesdowen.com\/blog\/#\/schema\/person\/51179280d7d76166490e1c27be360931"},"description":"Some time ago though, I was introduced to Idiorm by a co-developer on a large project. I've finally got round to using it.","breadcrumb":{"@id":"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jamesdowen.com\/blog\/finally-getting-round-to-using-idiorm-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jamesdowen.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Finally getting round to using Idiorm in PHP"}]},{"@type":"WebSite","@id":"https:\/\/jamesdowen.com\/blog\/#website","url":"https:\/\/jamesdowen.com\/blog\/","name":"James Dowen","description":"A blog about web development.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jamesdowen.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/jamesdowen.com\/blog\/#\/schema\/person\/51179280d7d76166490e1c27be360931","name":"James","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jamesdowen.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e4d7008d9ebb77f8de729f655e30d11f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e4d7008d9ebb77f8de729f655e30d11f?s=96&d=mm&r=g","caption":"James"},"sameAs":["http:\/\/jamesdowen.com"],"url":"https:\/\/jamesdowen.com\/blog\/author\/jdowen\/"}]}},"_links":{"self":[{"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/posts\/120"}],"collection":[{"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":6,"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":126,"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/posts\/120\/revisions\/126"}],"wp:attachment":[{"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jamesdowen.com\/blog\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}