Hi everybody,
i have a question.
In my database I have some many-to-many associations to manage.
I make an example.
I have a table PROJECTS, associated with a table WALKS.
One project can have many walks and one walk can belong to many
projects.
In the database i have a join table PROJECTS_WALKS that hold the ids of
these tables (FK).
I have not created a Model for the join table beacause throught the
bake.php I have defined that the Project model HABTM Walk (and vice
versa).
In this way I can easly have the related projects associated to a
specific walk, and the related walks belonging to a project, does it
make sense?
My problem is that the join table must have an attribute, as STATE. I
need that to get information about the state of the membership.
I have not found any examples in the manual about join tables with
atttributes.
I give you some istances:
ID_PR_1 - ID_W_1 - 0
ID_PR_1 - ID_W_2 - 1
ID_PR_2 - ID_W_2 - 0
I have to do some queries to check this attribute.
select projects.id, projects.name
from walks join projects_walks join projects
where
walks.id == projects_walks.walk.id
AND
projects.id == projects_walks.project_id
AND
walks_projects.state == 0
Is it possible to translate the query above with any fuctions like
find(), without the Model of the join table, using the Project or Walk
Model?
Afterwards I have to update the join table and the state attribut:
insert into projects_walks (project_id, walk_id, state)
value ($id_proj, $id_walk, $state)
How can I do that if I have not a Model for this table? Do I have to
built it?
If I make it, how can I associate the PROJECT_WALK model whit PROJECT
and WALK models?
Or is it better to use the QUERY/EXECUTE functions to make the SQL
generic query and do not create a specific model linked to the join
table?
Thanks so much for your help,
IlaFra
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---