Hello, I'm using the HABTM model association, with my database
structure as follows:
table: contractors
fields:
Id
name
address
state
zip
fax
table: projects
fields:
id
title
address
state
zip
type
value
size
..etc.
a join table:
contractors_projects
fields:
id
contractor_id
project_id
My question is, how can I insert data in to both "contractors" table
and "projects" table while maintaining the association?
My data is generated automatically, it looks something like this:
array(1) {
["Project"]=>
array(11) {
["id"]=>
NULL
["title"]=>
string(24) "Title of project goes here"
["address"]=>
string(43) " 123 Address here "
["state"]=>
string(2) "NC"
["zip"]=>
"12345"
["type"]=>
string(16) "New"
["value"]=>
string(0) ""
["size"]=>
string(17) "1000"
}
}
I then have an array of all the contractors that are associated with
this project:
array(4) {
[0]=>
array(8) {
["id"]=>
NULL
["name"]=>
string(36) "Contractor 1"
["address"]=>
string(34) " Address of Contractor 1, "
["state"]=>
string(2) "NC"
["zip"]=>
string(5) "12345"
["fax"]=>
string(10) "1231231234"
}
[1]=>
array(8) {
["id"]=>
NULL
["name"]=>
string(28) "Contractor 2"
["address"]=>
string(34) "Address of Contractor 2 "
["state"]=>
string(2) "NC"
["zip"]=>
string(5) "12345"
["fax"]=>
NULL
}
[2]=>
array(8) {
["id"]=>
NULL
["name"]=>
string(32) "Contractor 3"
["address"]=>
string(43) "Address of Contractor 3 "
["state"]=>
string(2) "NC"
["zip"]=>
string(5) "12345"
["fax"]=>
string(10) "1231231234"
}
}
How can I store (and in which order) the data in order to insert a new
project, AND a new contractor, but maintaining the association (that
the contractor belongs to that particular project)?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---