【发布时间】:2021-04-30 00:09:17
【问题描述】:
我正在使用 CodeIginter 4,并且我在控制器中实例化了一个新对象,来自我的 app/libraries 文件夹中的一个类,如下所示:
// in controller
use App\Libraries\LN_Account;
// in controller method
$account = new LN_Account();
但是当我将 $account 传递给我的模型并检查它是否是 LN_Account 的实例时,条件失败。
// in controller method
$account = $this->AuthenticationModel->getAuthenticationCredentials($account);
// in model
public function getAuthenticationCredentials($account) {
if ($account instanceof LN_Account) {
// I never get here
}
}
如何使 LN_Account 对我的模型可见?
我得到的错误是 LN_Account 不存在。它存在于控制器中就好了。在 CI3 中,控制器中可用的任何东西都在模型中可用。有变化吗?
【问题讨论】:
-
你能发布确切的错误日志吗?试试
is_a()而不是instanceof
标签: codeigniter object model codeigniter-4