URL http://beta.openaccessinc.com/users
On Aug 17, 3:46 pm, Magua <[email protected]> wrote: > I am now generating the following error when i load users > Warning (512): SQL Error: 1054: Unknown column 'User.organization_id' > in 'on clause' [CORE/cake/libs/model/datasources/dbo_source.php, line > 524] > > Here are my models > > organizaton.php > <? > class organization extends AppModel { > var $name = 'organization'; > var $hasMany = array('User'); > } > ?> > > type.php > <? > class type extends AppModel { > var $name = 'Type'; > var $hasMany = array('User');} > > ?> > > user.php > <? > class user extends AppModel { > var $name = 'User'; > var $belongsTo = array('Type','Organization'); > > } > > ?> > > On Aug 17, 3:18 pm, brian <[email protected]> wrote: > > > > > Just add the model to $belongsTo array. > > > User: > > var $belongsTo = array('Type', 'Organization'); > > > Organization: > > var $hasMany = array('User'); > > > On Mon, Aug 17, 2009 at 3:04 PM, Magua<[email protected]> wrote: > > > > Thanks I have it working now. > > > But i now need a another $belongs to declaration in my "user.php" > > > model. > > > How does cake handle this. > > > > For example i have now added an "organizations" table with the > > > following fields > > > id, name > > > > and i have added the following field to the "users" table. > > > organization_id > > > > Each user can only Belong To one organization. > > > > How is this done > > > > On Aug 17, 1:30 pm, brian <[email protected]> wrote: > > >> You forgot the "array" part: > > > >> var $hasOne = array('Type'); > > > >> BUT you probably want: > > > >> var $belongsTo = array('Type'); > > > >> Type: > > >> var $hasMany = array('User'); > > > >> If you used Group instead of Type it would make more sense. > > > >> On Mon, Aug 17, 2009 at 12:52 PM, Magua<[email protected]> wrote: > > > >> > Please note I am a very GREEN newby to MVC programing. > > > >> > I have 2 tables. > > >> > 1.> users > > >> > Fields: id, user, type_id > > >> > 2.> types > > >> > Fields: id, type > > > >> > Each user can have only 1 "type" and each "type" can have many > > >> > "users". > > >> > I have created the following models. > > > >> > user.php > > >> > <? > > >> > class User extends AppModel { > > >> > var $name = 'User'; > > >> > var $hasOne = 'Type'; > > >> > } > > >> > ?> > > >> > The above model generates this error. > > >> > Parse error: syntax error, unexpected '(' in /var/www/beta/htdocs/app/ > > >> > models/kind.php on line 4 > > > >> > type.php > > >> > <? > > >> > class type extends AppModel { > > >> > var $name = 'type'; > > >> > var $hasMany = ('user'); > > >> > } > > >> > ?> > > >> > The type error generates this error. > > >> > Parse error: syntax error, unexpected '(' in /var/www/beta/htdocs/app/ > > >> > models/type.php on line 4 > > > >> > What am i doing wrong? Is this not a hasOne Relationship. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~----------~----~----~----~------~----~------~--~---
