Hi All, not real sure how I should be setting this up. I have a join
table called scheduler_customers_tenant_service_approved with the
following 2 columns:
scheduler_customer_id (int)
tenant_service_approved_id (int).
The 2 tables that are being joined are:
table - scheduler_customers
pk = id
table - tenant_service_approved
pk = tenant_service_approved_id
(also has column called tenant_id to associate with tenant table)
I have this in my TenantServiceApproved Model
var $hasAndBelongsToMany = array(
'Customer' => array(
'className' => 'Customer',
'joinTable' =>
'scheduler_customers_tenant_service_approved',
'foreignKey' => 'tenant_service_approved_id',
'associatedForeignKey' => 'customer_id'
)
);
And this is in my Customer model
var $hasAndBelongsToMany = array(
'TenantServiceApproved' => array(
'className' => 'TenantServiceApproved',
'joinTable' =>
'scheduler_customers_tenant_service_approved',
'foreignKey' => 'scheduler_customer_id',
'associatedForeignKey' => 'tenant_service_approved_id',
'conditions' => null,
'fields' => null,
'order' => null,
'limit' => null,
'uniq' => false,
'offset' => null,
'fnderQuery' => null,
'deleteQuery' => null,
'insertQuery' => null
)
);
Now for the problem. Everything works fine for just one customer and
one tenant but a customer can belong to multiple tenants so when ever
a tenant changes a customer services (TenantServiceApproved) it
deletes all of the records in the
scheduler_customers_tenant_service_approved with that customer id even
though not all of the tenant_service_approved_id's belong to the
tenant that is making the changes.
Does this make since what I am trying to explain?
Basically when a tenant edits a customers service it deletes all
records for the customer rather than just the ones that belong to the
tentant.
In case this helps, I also have a table called tenant with a primary
key of tenant_id.
My tenant model has these associations:
var $hasAndBelongsToMany = array(
'Customer' =>
array('className' => 'Customer',
'joinTable' => 'scheduler_customers_tenant',
'foreignKey' => 'tenant_id',
'associationForeignKey'=> 'customer_id')
);
var $hasMany = array(
'TenantServiceApproved' => array(
'className' => 'TenantServiceApproved',
'foreignKey' => 'tenant_id'
));
Then I also have another join tabled called scheduler_customers_tenant
with 2 columns, customer_id (int) and tenant_id (int).
Should any of my associations be changed?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---