Loading db from an extended library |
[eluser]Unknown[/eluser]
Hello, I'm using CI 1.7.2 with PHP 5. I'm trying to load data from a db to populate an array inside a library (language) I extended (ie: MY_language). I tried doing the Code: $CI =& get_instance() Code: Call to undefined function get_instance() in /path/application/libraries/MY_Language.php on line [29] Why do I want to do this? I need to be able to load the supported languages (supported by my app) to 3 different files, and want it to be automatic instead of hand-edited like now. Any ideas? Thanks, Fefo
[eluser]placid2000[/eluser]
Hello, I m having a similar issue. have you already found a solution for this? I'm trying to load a database function in my extended MY_Form_Validation class but it says: Fatal error: Call to a member function get_where() on a non-object in.. the constructor looks like this: function MY_Form_Validation($config) { parent::CI_Form_validation($config); $CI =& get_instance(); $CI->load->database(); } Greetz Cyril
[eluser]danmontgomery[/eluser]
[quote author="placid2000" date="1268684384"]Hello, I m having a similar issue. have you already found a solution for this? I'm trying to load a database function in my extended MY_Form_Validation class but it says: Fatal error: Call to a member function get_where() on a non-object in.. the constructor looks like this: function MY_Form_Validation($config) { parent::CI_Form_validation($config); $CI =& get_instance(); $CI->load->database(); } Greetz Cyril[/quote] You're not declaring it as a class member... You need to use the $this keyword if you want to access it in other class methods. http://php.net/manual/en/language.variables.scope.php http://www.php.net/manual/en/language.oop5.basic.php
[eluser]Phil Sturgeon[/eluser]
Code: $IN =& load_class('Input'); Spot the issue there. get_instance() is set in Base4/Base5.php so this is not an error, just part of the architecture. You'd be better off making a MY_Controller which calls the database, then make a MY_Language that has a set_line() method to set your new lang items. |
Welcome Guest, Not a member yet? Register Sign In |