Hello,

Here's another 'hasMany/belongTo' question... :-)

I have read the user manual but either I didn't understood it or I am
goin' nuts... :-P

I have this DB structure:

Table 'users':
+------------+------------------+------+-----+---------
+----------------+
| Field      | Type             | Null | Key | Default |
Extra          |
+------------+------------------+------+-----+---------
+----------------+
| user_id    | int(10) unsigned | NO   | PRI | NULL    |
auto_increment |
| login      | varchar(25)      | NO   |     |
|                |
| password   | varchar(25)      | NO   |     |
|                |
| network_id | int(10) unsigned | NO   | MUL |
|                |
+------------+------------------+------+-----+---------
+----------------+

Table 'network':
+-------------+------------------+------+-----+---------
+----------------+
| Field       | Type             | Null | Key | Default |
Extra          |
+-------------+------------------+------+-----+---------
+----------------+
| network_id  | int(10) unsigned | NO   | PRI | NULL    |
auto_increment |
| name        | varchar(50)      | YES  |     | NULL
|                |
| description | varchar(100)     | YES  |     | NULL
|                |
| location    | varchar(25)      | YES  |     | NULL
|                |
+-------------+------------------+------+-----+---------
+----------------+

And this model code (using scaffolding for now, so no wicked
controller logic...):

class User extends AppModel
{

 var $name = 'User';
 var $useTable = 'users';
 var $primaryKey = 'user_id';

 var $belongsTo = array('Network' =>
                           array('className'  => 'Network',
                                 'conditions' => '',
                                 'order'      => '',
                                 'foreignKey' => 'network_id'
                           )
                     );
}

class Network extends AppModel
{
 var $name = 'Network';
 var $useTable = 'networks';
 var $primaryKey = 'network_id';

 var $hasMany = array('User' =>
                         array('className'     => 'User',
                               'conditions'    => '',
                               'order'         => '',
                               'limit'         => '',
                               'foreignKey'    => 'network_id',
                               'dependent'     => true,
                               'exclusive'     => false,
                               'finderQuery'   => ''
                         )
                  );
}

When I access the "network view" feature (http://localhost:8080/
networks/view/0/) I don't see any "Related Users".
I just get the "new user" option.

My question is: if I have the DB tables populated (there is a user
which belongs to network 0), shouldn't I get
to see that user listed on the screen when I view network 0?

Am I doing something wrong?

Thanks a lot!


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to