How do I use Model in Helper - CakePHP 2.x

cakephp, cakephp-2.0

Solution

working code should be

//let $modelName be User  
App::import("Model", "User");  
$model = new User();  
$model->find("list");  

I hope this will help some needy fellow

Problem

I recently upgraded my app from cake 1.3.x to cake 2.x. Now I have a helper which uses model in some function. Initially syntax for loading model was (working for 1.3.x) ``` App::import('Model', $modelName); $modelObject = &ClassRegistry::getObject($modelName); $modelObject->find() ``` Now I changed it to following ``` App::uses($modelName,'Model'); $modelObject = &ClassRegistry::getObject($modelName); $modelObject->find() ``` Problem is, this conversion is not working. Can anybody tell me where am I doing wrong. Thanking in advance. PS: Error message is: Call to a member function find() on a non-object

Original source