Hi everybody, I am just getting started with Cake and ran into
something that is stumping me.
If I build a controller this way everything works fine:
---------------------------------------------------------------
Would you like to build your controller interactively?
Warning: Choosing no will overwrite the CoursesController. (y/n)
[y] > y
Would you like to use scaffolding? (y/n)
[n] > y
---------------------------------------------------------------
The following controller will be created:
---------------------------------------------------------------
Controller Name: Courses
var $scaffold;
---------------------------------------------------------------
Look okay? (y/n)
[y] > y
When I build it this way (which I would think should be equivalent) I
get errors:
Would you like to build your controller interactively?
Warning: Choosing no will overwrite the CoursesController. (y/n)
[y] > n
Would you like to include some basic class methods (index(), add(),
view(), edit())? (y/n)
[y] > y
Would you like to create the methods for admin routing? (y/n)
[y] > n
---------------------------------------------------------------
The following controller will be created:
---------------------------------------------------------------
Controller Name: Courses
---------------------------------------------------------------
Look okay? (y/n)
[y] > y
After creating the controller non-interactively, I can hit refresh on
the index action and immediately see a "Notice (8): Undefined index"
error on two of my three foreign keys in that table.
The form for the add() action appears to be done correctly (the select
fields for my foreign key fields appear and are correctly populated)
but when I submit the form it fails and displays a SQL error and the
statement. Looking a the statement I realized that those same two
fields that show errors in the index view are missing from the insert
statement cake is trying to run.
Is this a problem with my database design that is screwing up
associations?
If so, why does it work fine with the "var $scaffold" and not the
other way?
Here is the structure of the offending table:
create table courses (
id int(11) unsigned not null auto_increment,
presenter varchar(60),
course_name varchar(100),
user_id int(11) unsigned,
course_date date,
start_time time,
address varchar(255),
city varchar(60),
state varchar(50),
country_id int(11) unsigned not null,
type_id int(11) unsigned not null,
course_description text,
index(id),
index(type_id),
index(country_id),
index(user_id),
constraint fk_type_id foreign key(type_id) references types(id) on
delete cascade,
constraint fk_country_id foreign key(country_id) references countries
(id) on delete cascade,
constraint fk_user_id foreign key(user_id) references users(id) on
delete cascade,
primary key(id)
) engine = innodb;
Help a brother out?
:)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---