{"id":665,"date":"2013-09-18T14:48:49","date_gmt":"2013-09-18T14:48:49","guid":{"rendered":"https:\/\/wade.one\/blog\/?p=665"},"modified":"2013-10-04T09:47:21","modified_gmt":"2013-10-04T09:47:21","slug":"c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class","status":"publish","type":"post","link":"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/","title":{"rendered":"C# MySqlDataReader &#8211; &#8220;one line&#8221; function to return a row as an instance of a class."},"content":{"rendered":"<p>MySql in C# is rather painless using the <a href=\"http:\/\/dev.mysql.com\/tech-resources\/articles\/mysql-installer-for-windows.html\">MySQL Connector for .net<\/a>, but one thing it is missing is a no-frills, no extra requirements, no pre-defined ERD return a row as an instance of a class function. Coming from a PHP background, I love the PDO function <a href=\"http:\/\/php.net\/manual\/en\/pdostatement.fetchobject.php\">fetchObject()<\/a>, it&#8217;s just right there and you get an object you can handle.<\/p>\n<p>I really wanted this functionality in my code to not only make it easier to read, but also make types easier to manage when returned from MySQL &#8211; why do I need to call GetString() or GetInt() when I can just say &#8220;look, the row that returns will look like this, return me an object with the properties set&#8221;.<\/p>\n<p>So I wrote a <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/vstudio\/bb383977.aspx\">static extension<\/a> function:<\/p>\n<pre>\/\/\/ &lt;summary&gt;\r\n\/\/\/ Grabs an instance of a class directly from the MySqlDataReader instead of manually building from GetString() etc.\r\n\/\/\/ &lt;\/summary&gt;\r\n\/\/\/ &lt;typeparam name=\"T\"&gt;Type of object to return&lt;\/typeparam&gt;\r\n\/\/\/ &lt;param name=\"reader\"&gt;Reader instance&lt;\/param&gt;\r\n\/\/\/ &lt;returns&gt;new T&lt;\/returns&gt;\r\npublic static T GetObject&lt;T&gt;(this MySql.Data.MySqlClient.MySqlDataReader reader)\r\n{\r\n    var obj = Activator.CreateInstance(typeof(T));\r\n    var fields = obj.GetType().GetFields();\r\n\r\n    foreach (var field in obj.GetType().GetFields())\r\n    {\r\n        var attrs = field.GetCustomAttributes(typeof(System.Runtime.Serialization.DataMemberAttribute), true) as System.Runtime.Serialization.DataMemberAttribute[];\r\n\r\n        if (attrs.Length == 0)\r\n        {\r\n            continue;\r\n        }\r\n\r\n        var fieldID = attrs[0].Name;\r\n        var fieldType = field.FieldType;\r\n\r\n        field.SetValue(obj, reader.GetValue(reader.GetOrdinal(fieldID)));\r\n    }\r\n\r\n    return (T)obj;\r\n}<\/pre>\n<p>This allows me to do something along the lines of <strong>reader.getObject&lt;MyClass&gt;()<\/strong> where MyClass would look something like this:<\/p>\n<pre>class MyClass\r\n{\r\n\u00a0 \u00a0\u00a0[DataMember(Name = \"id\")]\r\n    public int ID;\r\n\r\n    [DataMember(Name = \"email\")]\r\n    public string Email;\r\n\r\n    [DataMember(Name = \"full-name\")]\r\n    public string FullName;\r\n}<\/pre>\n<p>et voila, you&#8217;ve got an instance of MyClass where the MySQL columns are mapped to friendly properties on your object and the type hint makes it all clear as to what it is.<\/p>\n<p>As you can see, I&#8217;ve used the DataMember properties to define the SQL column name the data would come from, allowing the 1-1 mapping of SQL column to C# property.<\/p>\n<p>Now there are optimisations to be add here, I do not contest that, using reflection can slow things down a bit, caching would be a good idea for example. But this works perfectly for me and means rather than 3 lines:<br \/>\nobj.ID = GetInt(&#8220;id&#8221;);<br \/>\nobj.Email = GetString(&#8220;email&#8221;);<br \/>\nobj.FullName = GetString(&#8220;full-name&#8221;);<br \/>\nI now just have one clean line that uses the object I would have already used and populated manually.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySql in C# is rather painless using the MySQL Connector for .net, but one thing it is missing is a no-frills, no extra requirements, no pre-defined ERD return a row as an instance of a class function. Coming from a PHP background, I love the PDO function fetchObject(), it&#8217;s just right there and you get &#8230; <a href=\"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &#8220;C# MySqlDataReader &#8211; &#8220;one line&#8221; function to return a row as an instance of a class.&#8221;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-665","post","type-post","status-publish","format-standard","hentry","category-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>C# MySqlDataReader - &quot;one line&quot; function to return a row as an instance of a class. - wade.one<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# MySqlDataReader - &quot;one line&quot; function to return a row as an instance of a class. - wade.one\" \/>\n<meta property=\"og:description\" content=\"MySql in C# is rather painless using the MySQL Connector for .net, but one thing it is missing is a no-frills, no extra requirements, no pre-defined ERD return a row as an instance of a class function. Coming from a PHP background, I love the PDO function fetchObject(), it&#8217;s just right there and you get ... Read More &quot;C# MySqlDataReader &#8211; &#8220;one line&#8221; function to return a row as an instance of a class.&quot; &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/\" \/>\n<meta property=\"og:site_name\" content=\"wade.one\" \/>\n<meta property=\"article:published_time\" content=\"2013-09-18T14:48:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-10-04T09:47:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wade.one\/blog\/wp-content\/uploads\/2015\/02\/Wade-Logo-cropped.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1518\" \/>\n\t<meta property=\"og:image:height\" content=\"1506\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Wade\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@wadewomersley\" \/>\n<meta name=\"twitter:site\" content=\"@wadewomersley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Wade\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/2013\\\/09\\\/18\\\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/2013\\\/09\\\/18\\\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\\\/\"},\"author\":{\"name\":\"Wade\",\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/#\\\/schema\\\/person\\\/f9dedd948575256e77a44aa1417f63de\"},\"headline\":\"C# MySqlDataReader &#8211; &#8220;one line&#8221; function to return a row as an instance of a class.\",\"datePublished\":\"2013-09-18T14:48:49+00:00\",\"dateModified\":\"2013-10-04T09:47:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/2013\\\/09\\\/18\\\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\\\/\"},\"wordCount\":301,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/#\\\/schema\\\/person\\\/8b4739f8f8bb2cff5d792d4b8779fcc3\"},\"articleSection\":[\"Programming\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wade.one\\\/blog\\\/2013\\\/09\\\/18\\\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/2013\\\/09\\\/18\\\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\\\/\",\"url\":\"https:\\\/\\\/wade.one\\\/blog\\\/2013\\\/09\\\/18\\\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\\\/\",\"name\":\"C# MySqlDataReader - \\\"one line\\\" function to return a row as an instance of a class. - wade.one\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/#website\"},\"datePublished\":\"2013-09-18T14:48:49+00:00\",\"dateModified\":\"2013-10-04T09:47:21+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/2013\\\/09\\\/18\\\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wade.one\\\/blog\\\/2013\\\/09\\\/18\\\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/2013\\\/09\\\/18\\\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wade.one\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# MySqlDataReader &#8211; &#8220;one line&#8221; function to return a row as an instance of a class.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/wade.one\\\/blog\\\/\",\"name\":\"wade.one\",\"description\":\"wade womersley - york based software engineer\",\"publisher\":{\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/#\\\/schema\\\/person\\\/8b4739f8f8bb2cff5d792d4b8779fcc3\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wade.one\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/#\\\/schema\\\/person\\\/8b4739f8f8bb2cff5d792d4b8779fcc3\",\"name\":\"Wade Womersley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/02\\\/200px.png\",\"url\":\"https:\\\/\\\/wade.one\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/02\\\/200px.png\",\"contentUrl\":\"https:\\\/\\\/wade.one\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/02\\\/200px.png\",\"width\":202,\"height\":200,\"caption\":\"Wade Womersley\"},\"logo\":{\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/wp-content\\\/uploads\\\/2015\\\/02\\\/200px.png\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/wade.one\\\/blog\\\/#\\\/schema\\\/person\\\/f9dedd948575256e77a44aa1417f63de\",\"name\":\"Wade\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/94100ef7361b8aaac136b852c8df93bdd10942165a122d5c56e4466cc403e5d9?s=96&d=retro&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/94100ef7361b8aaac136b852c8df93bdd10942165a122d5c56e4466cc403e5d9?s=96&d=retro&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/94100ef7361b8aaac136b852c8df93bdd10942165a122d5c56e4466cc403e5d9?s=96&d=retro&r=pg\",\"caption\":\"Wade\"},\"url\":\"https:\\\/\\\/wade.one\\\/blog\\\/author\\\/wade\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C# MySqlDataReader - \"one line\" function to return a row as an instance of a class. - wade.one","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:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/","og_locale":"en_GB","og_type":"article","og_title":"C# MySqlDataReader - \"one line\" function to return a row as an instance of a class. - wade.one","og_description":"MySql in C# is rather painless using the MySQL Connector for .net, but one thing it is missing is a no-frills, no extra requirements, no pre-defined ERD return a row as an instance of a class function. Coming from a PHP background, I love the PDO function fetchObject(), it&#8217;s just right there and you get ... Read More \"C# MySqlDataReader &#8211; &#8220;one line&#8221; function to return a row as an instance of a class.\" &raquo;","og_url":"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/","og_site_name":"wade.one","article_published_time":"2013-09-18T14:48:49+00:00","article_modified_time":"2013-10-04T09:47:21+00:00","og_image":[{"width":1518,"height":1506,"url":"https:\/\/wade.one\/blog\/wp-content\/uploads\/2015\/02\/Wade-Logo-cropped.png","type":"image\/png"}],"author":"Wade","twitter_card":"summary_large_image","twitter_creator":"@wadewomersley","twitter_site":"@wadewomersley","twitter_misc":{"Written by":"Wade","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/#article","isPartOf":{"@id":"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/"},"author":{"name":"Wade","@id":"https:\/\/wade.one\/blog\/#\/schema\/person\/f9dedd948575256e77a44aa1417f63de"},"headline":"C# MySqlDataReader &#8211; &#8220;one line&#8221; function to return a row as an instance of a class.","datePublished":"2013-09-18T14:48:49+00:00","dateModified":"2013-10-04T09:47:21+00:00","mainEntityOfPage":{"@id":"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/"},"wordCount":301,"commentCount":1,"publisher":{"@id":"https:\/\/wade.one\/blog\/#\/schema\/person\/8b4739f8f8bb2cff5d792d4b8779fcc3"},"articleSection":["Programming"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/","url":"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/","name":"C# MySqlDataReader - \"one line\" function to return a row as an instance of a class. - wade.one","isPartOf":{"@id":"https:\/\/wade.one\/blog\/#website"},"datePublished":"2013-09-18T14:48:49+00:00","dateModified":"2013-10-04T09:47:21+00:00","breadcrumb":{"@id":"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wade.one\/blog\/2013\/09\/18\/c-mysqldatareader-one-line-function-to-return-a-row-as-an-instance-of-a-class\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wade.one\/blog\/"},{"@type":"ListItem","position":2,"name":"C# MySqlDataReader &#8211; &#8220;one line&#8221; function to return a row as an instance of a class."}]},{"@type":"WebSite","@id":"https:\/\/wade.one\/blog\/#website","url":"https:\/\/wade.one\/blog\/","name":"wade.one","description":"wade womersley - york based software engineer","publisher":{"@id":"https:\/\/wade.one\/blog\/#\/schema\/person\/8b4739f8f8bb2cff5d792d4b8779fcc3"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wade.one\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/wade.one\/blog\/#\/schema\/person\/8b4739f8f8bb2cff5d792d4b8779fcc3","name":"Wade Womersley","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/wade.one\/blog\/wp-content\/uploads\/2015\/02\/200px.png","url":"https:\/\/wade.one\/blog\/wp-content\/uploads\/2015\/02\/200px.png","contentUrl":"https:\/\/wade.one\/blog\/wp-content\/uploads\/2015\/02\/200px.png","width":202,"height":200,"caption":"Wade Womersley"},"logo":{"@id":"https:\/\/wade.one\/blog\/wp-content\/uploads\/2015\/02\/200px.png"}},{"@type":"Person","@id":"https:\/\/wade.one\/blog\/#\/schema\/person\/f9dedd948575256e77a44aa1417f63de","name":"Wade","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/94100ef7361b8aaac136b852c8df93bdd10942165a122d5c56e4466cc403e5d9?s=96&d=retro&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/94100ef7361b8aaac136b852c8df93bdd10942165a122d5c56e4466cc403e5d9?s=96&d=retro&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/94100ef7361b8aaac136b852c8df93bdd10942165a122d5c56e4466cc403e5d9?s=96&d=retro&r=pg","caption":"Wade"},"url":"https:\/\/wade.one\/blog\/author\/wade\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":453,"url":"https:\/\/wade.one\/blog\/2010\/02\/26\/phpuk2010-part-2-mysql-stuff\/","url_meta":{"origin":665,"position":0},"title":"#PHPUK2010 Part 2 (MySQL stuff)","author":"Wade","date":"February 26, 2010","format":false,"excerpt":"Just picked up a nice tid-bit on creating a unique index on a two column table where the values in each column may be either way around but you only ever want one instance of the value in that row. So what this means is, inserting 2,1 and 1,2 for\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/wade.one\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":95,"url":"https:\/\/wade.one\/blog\/2009\/09\/10\/linux-raid-mysql\/","url_meta":{"origin":665,"position":1},"title":"Linux RAID, MySQL","author":"Wade","date":"September 10, 2009","format":false,"excerpt":"Ubuntu...it's a great Linux OS to use on servers due to its speed and simplicity - personal preference based on no statistics, only personal use. However, one thing Linux drives me mad with is software RAID. It's taken me the better part of a day to set up a few\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/wade.one\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":463,"url":"https:\/\/wade.one\/blog\/2010\/04\/12\/reset-mysql-root-password-if-you-forgot-it-mysql\/","url_meta":{"origin":665,"position":2},"title":"Reset MySQL root password if you forgot it #mysql","author":"Wade","date":"April 12, 2010","format":false,"excerpt":"Just had a need to reset the mysql root login password for a server, did a bit of Googling and found out this is how you do it (I work on Ubuntu so you may have to tinker with the lines slightly depending on your distribution): Stop the current MySQL\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/wade.one\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":437,"url":"https:\/\/wade.one\/blog\/2010\/01\/31\/mysql-and-binary16-the-reasonsbenefitsdrawbacks-mysql\/","url_meta":{"origin":665,"position":3},"title":"MySQL and Binary(16) &#8211; The Reasons\/Benefits\/Drawbacks (#mysql)","author":"Wade","date":"January 31, 2010","format":false,"excerpt":"I recently posted an article about using BINARY(16) for storing MD5's as unique identifiers instead of simple integer ID's (usually auto increment); in that article I touched on one of the benefits, reducing JOIN's, but there are other reasons for doing it too, so I thought I'd post an article\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/wade.one\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":431,"url":"https:\/\/wade.one\/blog\/2010\/01\/29\/mysql-binary16-and-scalability\/","url_meta":{"origin":665,"position":4},"title":"MySQL &#8211; Binary(16) and scalability","author":"Wade","date":"January 29, 2010","format":false,"excerpt":"Over the past few months at work, we've seen our database grown from silly big to really silly big, it's still a way to go to get to the size of the big boys such as Facebook etc. but it's still a database stored in MySQL that most day-to-day PHP\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/wade.one\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":629,"url":"https:\/\/wade.one\/blog\/2012\/10\/15\/using-amazon-ec2-with-c-net\/","url_meta":{"origin":665,"position":5},"title":"Using Amazon EC2 with C# .net","author":"Wade","date":"October 15, 2012","format":false,"excerpt":"Amazon's EC2 platform has a very in-depth console which allows you to do a lot, but what if you want to automate some of the processes or handling servers? I've been working with EC2 a lot recently and automating server starting\/stopping based on parameters of the system we use here\u2026","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/wade.one\/blog\/category\/programming\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/posts\/665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/comments?post=665"}],"version-history":[{"count":2,"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/posts\/665\/revisions"}],"predecessor-version":[{"id":669,"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/posts\/665\/revisions\/669"}],"wp:attachment":[{"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/media?parent=665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/categories?post=665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wade.one\/blog\/wp-json\/wp\/v2\/tags?post=665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}