0

I want to use different databases for different language files. I can get language code with this;

$this->lang->lang()

I have to define it as pre_controller hook, so system will select right database at the beginning. But when I try to use the code above, I'm getting a fatal error.

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Hooks::$lang

Filename: config/hooks.php

Line Number: 13

Fatal error: Call to a member function lang() on a non-object in...

This is my code;

$hook['pre_controller'] = define('LANG', isset($_SESSION['lang']) ? $_SESSION['lang'] : $this->lang->lang());

Thanks in advance.

4
  • Try this. $this->CI->lang->lang()
    – Trushali
    Oct 20, 2014 at 4:47
  • Same. Call to a member function lang() on a non-object Oct 20, 2014 at 13:09
  • Try this. It should be work. $CI =& get_instance(); $CI->lang->lang();
    – Trushali
    Oct 21, 2014 at 6:52
  • I got different error now; Fatal error: Class 'CI_Controller' not found in C:\xampp\htdocs\firmav1\system\core\CodeIgniter.php on line 233 Oct 21, 2014 at 9:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.