Why are some classes created on the fly and others aren't in CakePHP 1.2.7?

Posted by JoseMarmolejos on Stack Overflow See other posts from Stack Overflow or by JoseMarmolejos
Published on 2010-05-31T20:38:18Z Indexed on 2010/05/31 20:43 UTC
Read the original article Hit count: 131

Filed under:
|
|
|

I have the following model classes:

class User extends AppModel {
var $name= 'User';
var $belongsTo=array('SellerType' => array('className' => 'SellerType'),
                        'State' => array('className' => 'State'),
                        'Country' => array('className' => 'Country'),
                        'AdvertMethod' => array('className' => 'AdvertMethod'),
                        'UserType' => array('className' => 'UserType'));

var $hasMany = array('UserQuery' => array('className' => 'UserQuery'));}

And:

class UserQuery extends AppModel {
var $name = 'UserQuery';
var $belongsTo = array('User', 'ResidenceType', 'HomeType');}

Everything works fine with the user class and all its associations, but the UserQuery class is being completely ignored by the orm (table name user_queries and the generated queries do cast it as UserQuery. Another weird thing is that if I delete the code inside the User class I get an error, but if I do the same for the UserQuery class I get no errors.

So my question is why does cakephp generate a class on the fly for the UserQuery and ignores my class, and why doesn't it generate a class on the fly for the User as well ?

© Stack Overflow or respective owner

Related posts about php

Related posts about orm