Re: How to save data in an associative model without deleting the old related records.

2010-03-12 Thread WebbedIT
id | shop_id | service_id | price And when I change the data, I lose the field price Ahh, so we're not talking about a standard HABTM as the join table has extra fields. Surely whenever adding/editing links you will also need to show the price incase it needs updating. So why are you not

Re: How to save data in an associative model without deleting the old related records.

2010-03-11 Thread Weather Forecaster
@WebbedIT I need to keep the old records as I am in them to store additional information. In tabel ShopsMainService i write down the price of services. and I get id | shop_id | service_id | price And when I change the data, I lose the field price On Mar 10, 11:02 am, WebbedIT

Re: How to save data in an associative model without deleting the old related records.

2010-03-11 Thread nurvzy
@WebbedIT 'unique' = false does indeed stop cake from running a deleteAll on the join table before inserting new records. The benefit of this is it makes adding additional 'tags' much easier. Consider the following: If all you want to do is add a new link between two models, if unique is set to

Re: How to save data in an associative model without deleting the old related records.

2010-03-10 Thread WebbedIT
@Weather It is standard practice on a HABTM join table to delete all existing records then run a new insert, this is the most efficient way to do it as requires fewer SQL calls and PHP loops, plus it ensures there is no duplication of selected options which would cause problems at a later date

Re: How to save data in an associative model without deleting the old related records.

2010-03-09 Thread nurvzy
To get what you want you'll need to set 'unique' = false within your declaration of HABTM association in your model. //models/shop.php var $hasAndBelongsToMany = array( 'MainService' = array( 'className' = 'MainService', 'unique' = false, ) ); Here is the documentation of all the

How to save data in an associative model without deleting the old related records.

2010-03-09 Thread Weather Forecaster
How do I make so that Cakephp not delete related records before adding, new. There are two models of Shop and MainService. Contact them so: class Shop extends AppModel { var $hasAndBelongsToMany = array( 'MainService' = array( 'className'