Heh, normally, having the link wouldn't do much good; you'd need to
provide your find() code. But:

SELECT `User`.`id`, `User`.`type_id`, `User`.`organizations_id`, ...

It looks to me like you created a column named 'organizations_id'
rather than 'organization_id'. The latter is what you want. Cake
picked it up when it issued 'DESCRIBE users' in order to get the table
schema. So, your code is probably good and you just need to modify the
column name.

On Mon, Aug 17, 2009 at 4:08 PM, Magua<mdm...@gmail.com> wrote:
>
> URL
> http://beta.openaccessinc.com/users
>
>
> On Aug 17, 3:46 pm, Magua <mdm...@gmail.com> 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 <bally.z...@gmail.com> 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<mdm...@gmail.com> 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 <bally.z...@gmail.com> 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<mdm...@gmail.com> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to