How to call a config item |
[eluser]satie[/eluser]
Why if I use Code: $var = $this->config->item('encryption_key'); CI returns PHP Fatal error: Call to a member function item() on a non-object ... The documentation says: To retrieve an item from your config file, use the following function: Code: $this->config->item('item name'); Thanks
[eluser]PhilTem[/eluser]
Give us a little more code that runs prior and after your $var = ... code. If you're not in an object environment or have not assigned the CI super object to $this (i.e. you have that line in a library and not a controller or model) then you cannot use $this
[eluser]InsiteFX[/eluser]
It depends on where you are calling it from, if you are trying to call it from a library or helper then you need to use the CodeIgniter super object. Code: class Some_lib {
[eluser]satie[/eluser]
Yes, sorry about lack of code. @InsiteFX, thanks for your answer but if i put your code in my model CI returns Quote:Severity: Warning My question with more details I have a model function Code: public function insert() So in my custom "funzioni" there is the 'pre_password' function: Code: function pre_password($password)
[eluser]InsiteFX[/eluser]
Sorry about that I forgot to remove the $config from the constructor It came from one of my libraries, I fixed the code above it should work now.
[eluser]satie[/eluser]
Ohh, I'm so stupid: I had not noticed. Works! Thanks I put your code not in the model, but in my custom class "funzioni" (./application/libraries/funzioni.php); Thanks to @PhilTem too. |
Welcome Guest, Not a member yet? Register Sign In |