我不明白为什么我不能将这个自己编写的模型加载到我的控制器中。型号代码:
class Storage extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
function getStorageByID( $storageID, $accountID = -1 )
{
$query = $this->db->select('*')->from('storage')->where('storageID', $storageID);
if ($accountID != -1)
$query->where('storageAccountID', $accountID);
return $this->finishQuery( $query );
}
function getStorageByAccount( $accountID )
{
$query = $this->db->select('*')->from('storage')->where('storageAccountID', $accountID)->limit( $limit );
return $this->finishQuery( $query );
}
function finishQuery( $query )
{
$row = $query->get()->result();
return objectToArray($row);
}
}
控制器中用于加载和执行的代码:
$this->load->model('storage'); // Line 147
$storageDetails = $storage->getStorageByAccount( $userData['accountID'] ); // Line 148
错误:
Message: Undefined variable: storage
Filename: controllers/dashboard.php
Line Number: 148
Fatal error: Call to a member function getStorageByAccount() on a non-object in /home/dev/concept/application/controllers/dashboard.php on line 148
我试过 var_dump'ing 模型加载命令,但它只返回 NULL。
提前致谢。