As documented on the new version notes you should now loading a model before
manually instantiating its class:
loadModel('Location');
$Location = new Location;
$data = $Location -> findAll();
$this->controller->set('ChooseLocation',$data);
loadModel('Category');
$Category = new Category;
$my_data = $Category->findAll();
-MI
---------------------------------------------------------------------------
Remember, smart coders answer ten questions for every question they ask.
So be smart, be cool, and share your knowledge.
BAKE ON!
________________________________________
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de Bernard Grosperrin
Enviado el: Jueves, 07 de Diciembre de 2006 07:53 p.m.
Para: [email protected]
Asunto: Error after upgrading to 1.1.11.4064 on new ModelName()
I just upgraded to the last version, and get an error I don't understand:
Fatal error: Class 'Location' not found in
C:\ApacheSSL\htdocs\cake\app\controllers\components\choose_location.php on
line 12
here is the code in choose_location:
class ChooseLocationComponent extends Object
{
var $controller = true;
// I have to find a way to have a function here which can receive
parameters(or not)
// and would find only the locations for the current user
function startup (&$controller)
{
$this->controller = &$controller;
$Location = new Location;
$data = $Location -> findAll();
$this->controller->set('ChooseLocation',$data);
$Category = new Category;
$my_data = $Category->findAll(); // now you are able to do
this
$this->controller->set('category_list',
$my_data);
}
}
Location is a model, and this was causing no problems with the previous
version I was using (noted in the files as revision 1.1, 2006/08/09
14:48:55.
I read this note : "The change results in a need to make sure you
loadModel('ModelName'); if you use $ModelName = new ModelName() somewhere in
your code. We have seen several examples, particularly in reference to
components creating model instances. This was not recommended practice, so
remember that you need to load the model now if you plan on creating an
instance."
But when I change the above code to read:
class ChooseLocationComponent extends Object
{
var $controller = true;
// I have to find a way to have a function here which can receive
parameters(or not)
// and would find only the locations for the current user
function startup (&$controller)
{
$this->controller = &$controller;
loadModel('Location');
loadModel('Category');
$Location = new Location;
$data = $Location -> findAll();
$this->controller->set('ChooseLocation',$data);
$Category = new Category;
$my_data = $Category->findAll(); // now you are able to do
this
$this->controller->set('category_list',
$my_data);
}
}
I get the very same error, line 14 instead of 12, logic!
Is there something in the configuration I should have taken care off,
somewhere, or is my code not making sense?
For now, I have simply changed back CAKE_CORE_INCLUDE_PATH, as cake is in
his own C:\cake directory, while app is under Apache\htdocs.
Thanks for you help,
Bernard
__________ Información de NOD32, revisión 1909 (20061207) __________
Este mensaje ha sido analizado con NOD32 antivirus system
http://www.nod32.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---