{"id":7279,"date":"2014-06-03T23:34:44","date_gmt":"2014-06-03T23:34:44","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/03\/codeigniter-unexpected-model-load-collection-of-common-programming-errors\/"},"modified":"2014-06-03T23:34:44","modified_gmt":"2014-06-03T23:34:44","slug":"codeigniter-unexpected-model-load-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/03\/codeigniter-unexpected-model-load-collection-of-common-programming-errors\/","title":{"rendered":"codeigniter unexpected model load-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m building an app where it contains 3 mysql database connections to 3 different databases. Ex. 1. Default connection =&gt; DB1 2. conn02 =&gt; DB2 3. conn03 =&gt; DB3<\/p>\n<p>All this 3 connections use same username and password.<\/p>\n<p>I called other 2 connections in model construct since it was not default. like:<\/p>\n<pre><code>$this-&gt;CONN2 = $this-&gt;load-&gt;database('db2', TRUE);\n$this-&gt;CONN3 = $this-&gt;load-&gt;database('db3', TRUE);\n<\/code><\/pre>\n<p>Later when i called this model in controller and while rendering the view. It was taking around 7 seconds to render the view in browser. Which was long time for a view to load in browser without any db select queries.<\/p>\n<p>Then i benchmarked the model and saw the result. I came to know that model was taking time. So i disabled the database connections in the model at construct and it was loading fast. I was surprised to see the result.<\/p>\n<p>Can you please tell me how to solve this issue?<\/p>\n<p>Here is the image of benchmark result before and after disabling the database connections in model.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/Wkzvt.jpg\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m building an app where it contains 3 mysql database connections to 3 different databases. Ex. 1. Default connection =&gt; DB1 2. conn02 =&gt; DB2 3. conn03 =&gt; DB3 All this 3 connections use same username and password. I called other 2 connections in model construct since it was not default. like: $this-&gt;CONN2 = $this-&gt;load-&gt;database(&#8216;db2&#8217;, [&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-7279","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7279","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=7279"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7279\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}