@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 true you first have to grab all the currently
linked ids and then append your new id to that list and re-save.  If
unique is set to false, all you'll have to do is pass in the new tag
id and all your previous records are preserved (a constant time
operation rather than an N time).

At a web interface level it doesn't make much sense to set unique to
false because maintaining database integrity will be a bitch. The
benefit of a HABTM relationship in CakePHP is the join table and model
is suppose to be invisible to you as the developer. Turning unique =>
false is pretty much saying "I'll handle the join table integrity
myself cake".  It's now up to the developer to maintain database
integrity.

That's how I like to think of it anyway,
Nick


I create a blog and assign some tags to it.
On Mar 10, 2:02 am, WebbedIT <p...@webbedit.co.uk> wrote:
> @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 when updating selections.
>
> Why is this a problem to you?
>
> @nurvzy
> Does 'unique' => 'false' really stop cake running a deleteAll on the
> join table before inserting the new records?
>
> And would you want to allow duplicate records in your join table?
> What would you do with those duplicate records as there is no standard
> way to use a form to de-select an option if it has been chosen twice?
>
> HTH
>
> Paul.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to