Vikramraj
Vikramraj

Reputation: 198

What is a proper way to use model inside component in cakephp?

When calling Partner model from component it is showing error.

App::import("MyPlugin.Model", "Partner");
$objPartner = new Partner();

Fatal error: Class 'Partner' not found in D:\htdocs\myapp\app\Plugin\MyPlugin\Controller\Component\TestComponent.php on line 287

Upvotes: 2

Views: 2496

Answers (1)

mark
mark

Reputation: 21743

Never use App::import. Always either use loadModel in controller or shell scope or the always working

$Partner = ClassRegistry::init('Partner');

Upvotes: 6

Related Questions