0
我想根据$ _SESSION变量在我的一个CodeIgniter模型中更改表名。该变量决定语言,我想根据所选语言查询不同的表。如何根据会话变量确定CodeIgnitor模型中的表名
现在我有这样的:
<?php if (!defined('BASEPATH')) exit ('No direct script access allowed');
class Tp_modules_model extends DataMapper {
public function __construct(){
parent::__construct();
}
public $table = determineTable($_SESSION['lang']);
public function getModules($ids) {
$this->clear();
return $this->where_in('id', $ids)->get()->all_to_array();
}
public function determineTable($lang) {
if ($lang == 'nl') {
return 'modules_dutch';
} else {
return 'modules';
}
}
}
但我收到此错误信息:
Parse error: syntax error, unexpected '(', expecting ',' or ';' in /usr/www/users/staginntkx/application/modules/ecom_bookings/models/tp_modules_model.php on line 9
是否有这种或者其他的方式解决办法来改变基于输出我的模型表$ _SESSION ['lang']?任何帮助将是伟大的,谢谢!