Hello all,
I am fairly new to CakePHP and was following some examples and found a
problem:
The example I was playing with has the following two tables:
CREATE TABLE `products` (
`id` INT(10) not null auto_increment,
`title` VARCHAR(255) not null,
`dealer_id` INT(10) not null,
`description` blob not null,
PRIMARY KEY(`id`)
)TYPE=MYISAM;
CREATE TABLE `dealers` (
`id` INT(10) NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
PRIMARY KEY(`id`)
)TYPE=MYISAM;
and the following Model classes:
class Product extends AppModel
{
var $name = 'Product';
var $belongsTo = array('Dealer' => array( 'className' => 'Dealer',
'conditions' => '',
'order'
=> '',
'foreignKey' => 'dealer_id'));
}
class Dealer extends AppModel
{
var $name = 'Dealer';
var $hasMany = array('Product' => array( 'className' =>
'Product',
'conditions' => '',
'order'
=> '',
'foreignKey' => 'dealer_id'));
}
The products controller is defined as:
class ProductsController extends AppController
{
var $scaffold;
}
Then I have some test data populated into the "Dealers" table. At run
time, as expected, I get a drop down list populated with the dealer
records when trying to create a new Product. No problem here.
The problem comes when I try to apply the same code to the following
tables:
CREATE TABLE `users` (
`id` int not null auto_increment,
`username` varchar(16) not null,
`password` varchar(128) not null,
`email` varchar(255) not null,
`user_type_id` int not null,
PRIMARY KEY (`id`)
)Type=MyISAM;
CREATE TABLE `user_types` (
`id` int not null auto_increment,
`name` varchar(32) not null,
PRIMARY KEY (`id`)
)Type=MyISAM;
With the following Models:
class User extends AppModel
{
var $name = 'User';
var $belongsTo = array('UserType' =>
array( 'className' => 'UserType',
'conditions' => '',
'order' => '',
'foreignKey' => 'user_type_id'));
}
class UserType extends AppModel
{
var $hasMany = array('User' => array( 'className' => 'User',
'conditions' =>
'',
'order' => '',
'foreignKey' =>
'user_type_id'));
}
And a Controller defined as:
class UsersController extends AppController
{
var $scaffold;
}
Again I have the user_types table populated with some test values.
However they do not get read when I try to create a new User record.
Is there something I am missing here?
I am using CakePHP 1.1.19.6305
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---