【发布时间】:2016-03-13 11:45:19
【问题描述】:
我的 Model/ 目录中有一个充满静态函数的类,我称之为 UtilityFunctions。但是即使“使用”语句到位,该类也无法访问 TableRegistry::Get。下面是代码和错误。
namespace App\Model\Table;
use Cake\ORM\TableRegistry;
use App\Model\Entity\Device;
class UtilityFunctions {
public static function getDevice($deviceInfo) {
$devicesTable = TableRegistry::get('Devices'); // TableRegistry not found
$query = $devicesTable->findByDeviceInfo($deviceInfo);
...
}
}
"找不到类\u0027UtilityFunctions\TableRegistry\u0027", "/var/www/myserver/src/Model/Custom/UtilityFunctions.php",115
【问题讨论】:
-
我认为是因为它是在静态函数中调用的,尝试在开头添加反斜杠 -
\TableRegistry::get('Devices') -
你是怎么调用那个方法的?
标签: mysql cakephp-3.0