CakePHP致命错误:调用未定义的方法stdClass::findById()

CakePHP致命错误:调用未定义的方法stdClass::findById(),php,cakephp,fatal-error,Php,Cakephp,Fatal Error,可能重复: 我犯了这样的错误 Fatal error: Call to undefined method stdClass::findById() in C:\wamp\www\studiohelper\app\controllers\recurring_invoices_controller.php on line 309 下面是该行的代码: $invoice = $this->Invoice->findById($invoiceId); 它看起来像是一个非常基本的代码,但我

可能重复:

我犯了这样的错误

Fatal error: Call to undefined method stdClass::findById() in C:\wamp\www\studiohelper\app\controllers\recurring_invoices_controller.php on line 309
下面是该行的代码:

$invoice = $this->Invoice->findById($invoiceId);

它看起来像是一个非常基本的代码,但我到底为什么会出现这种错误?

我认为您的型号名称中存在错误。实际上,在蛋糕php中是这样的

$this->Modelname->findById($id);

请在您的型号中检查型号名称是否为Invoice或RecurringInvoice。请确保这一点。

此->发票来自哪里?我们需要看到更多的代码。这就是你在Cakephpo中调用模型的方式,很明显你遗漏了一些东西。好的,我只是通过在上面添加这段代码来解决它:var$uses=array('RecurringInvoice','Invoice');对不起,这里没有。@tereško可能重复吗?什么?!你在跟我开玩笑啊!?哈哈哈!