Issue
I have a controller name CodeBridgeController
and have a model table name CodeBridgeTable
.
When I call CodeBridge table in action like following:
$this->CodeBridge->find('all')->toArray();
This generate Error: Call to a member function find() on a non-object
File D:\php\htdocs\cake3\erp\src\Controller\CodeBridgeController.php
Line: 25
I think this is silly matter but i could not find any wrong in the code why table is not loaded in this context.
When i call this way it works.
$codeBridgeTable = TableRegistry::get('CodeBridge');
$results = $codeBridgeTable->find('all')->hydrate(false)->toArray();
What may create the problem, expert suggestion needed.
Solution
Finally, I found where the problem lies.
In controller action, I generating a url like following:
Router::url(array('controller' =>'codebridge','action'=>'edit'));
which generate url /cake3/erp/codebridge/edit
After changing the controller name in camel case Router::url(array('controller' =>'CodeBridge','action'=>'edit'));
which generate url '/cake3/erp/code-bridge/edit`
This solve the problem
Answered By - karim_fci
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.