{"id":794,"date":"2022-08-30T15:07:17","date_gmt":"2022-08-30T15:07:17","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/codeigniter-database-error-in-selecting-data-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:07:17","modified_gmt":"2022-08-30T15:07:17","slug":"codeigniter-database-error-in-selecting-data-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/codeigniter-database-error-in-selecting-data-collection-of-common-programming-errors\/","title":{"rendered":"codeigniter database error in selecting data-Collection of common programming errors"},"content":{"rendered":"<p><code>crime_details.report_ID<\/code> holds a <code>VARCHAR<\/code>, so your where condition should be<\/p>\n<pre><code>WHERE crime_details.report_ID = 'BA-12-00002'\n<\/code><\/pre>\n<p>i.e., you need to wrap the value in quotes.<\/p>\n<p>Also, instead of using <code>$this-&gt;db-&gt;query()<\/code> to run your hand-written MySQL query, you should use ActiveRecord&#8217;s query builder which would have taken care of this for you. For example, you could have done:<\/p>\n<pre><code>$query = $this-&gt;db-&gt;get_where('crime_reports', array( 'report_ID' =&gt; 'BA-12-00002' ));\n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:45:52. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>crime_details.report_ID holds a VARCHAR, so your where condition should be WHERE crime_details.report_ID = &#8216;BA-12-00002&#8242; i.e., you need to wrap the value in quotes. Also, instead of using $this-&gt;db-&gt;query() to run your hand-written MySQL query, you should use ActiveRecord&#8217;s query builder which would have taken care of this for you. For example, you could have done: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-794","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=794"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/794\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}