我在我的静态函数中尝试调用CodeIgniter方法时遇到了麻烦,只是使用$这不起作用,因为它不在对象上下文中,静态关键字也不起作用.这是我的核心模型中的代码示例,$ table变量是从另一个模型(如posts)成功定义的.
class MY_Model extends CI_Model {
protected static $table;
public function __construct() {
parent::__construct();
}
public static function find_all() {
$this->db->select('*');
$sql = $this->db->get(static::$table);
return $sql->result();
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3192 次 |
最近记录: |