{"id":237,"date":"2022-08-30T14:58:00","date_gmt":"2022-08-30T14:58:00","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/08\/31\/codeigniter-undefined-property-xxxx_modeldb-only-from-model-record-and-share-programming-errors\/"},"modified":"2022-08-30T14:58:00","modified_gmt":"2022-08-30T14:58:00","slug":"codeigniter-undefined-property-xxxx_modeldb-only-from-model-record-and-share-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/codeigniter-undefined-property-xxxx_modeldb-only-from-model-record-and-share-programming-errors\/","title":{"rendered":"Codeigniter Undefined property: xxxx_model::$db only from Model-Record and share programming errors"},"content":{"rendered":"<p>To add to atno&#8217;s answer:<\/p>\n<pre><code>class Xxxx_model extends Model\n{\n  function XxxxModel() \/\/load-&gt;database();\n  }\n<\/code><\/pre>\n<p>Basically, you are not constructing the class <strong><em>or<\/em><\/strong> the parent class <code>Model<\/code>. If you are on PHP5, you may use <code>__construct()<\/code>, otherwise you must match the class name exactly, regardless of what alias you load it with in your controller. Example:<\/p>\n<pre><code>class Xxxx_model extends Model\n{\n  function __construct()\n  {\n    parent::__construct(); \/\/ construct the Model class\n  }\n}\n<\/code><\/pre>\n<p>I may be mistaken (haven&#8217;t used 1.x in a while), but if you construct the Model class, there&#8217;s no need to load the database if you are using the default connection settings in <code>config\/database.php<\/code>, it should already be loaded for you.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-08-31 05:56:37. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>To add to atno&#8217;s answer: class Xxxx_model extends Model { function XxxxModel() \/\/load-&gt;database(); } Basically, you are not constructing the class or the parent class Model. If you are on PHP5, you may use __construct(), otherwise you must match the class name exactly, regardless of what alias you load it with in your controller. Example: [&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-237","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/237","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=237"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/237\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}