Pablo,

The relationships you create in Cake are handled by setting any of the
following model properties:

- hasOne
- hasMany
- belongsTo
- hasAndBelongsToMany

You are probably familiar with this already if you're using Cake at
all. The relationships don't require the database tables themselves to
have foreign key constraints. In fact, in all of my applications, I do
not have constraints between my database tables in MySQL. In MySQL's
eyes, all my tables are 100% independent of each other.

Instead, I relate all my tables together at the application level.
Specifically, at the model level. This enables me to use all of Cake's
power such as dependent = true and the delete callbacks.

By relating your tables together at the model layer in Cake, and
setting dependent = true (valid for hasOne and hasMany only, btw),
Cake will automatically find the related records and delete them for
you even though MySQL does not have these tables connected with a
foreign key constraint.

HTH

- Kevin (etipaced)

On Apr 10, 9:03 pm, "Pablo Vergara B." <pabloandre...@gmail.com>
wrote:
> How do you actually can use database CASCADE deleting method when no
> "real" relations are made into the database diagram? (Because
> relations are handled internally by cakePHP)
>
> I'm still a novice about cakePHP so I can be wrong... or not. Let's
> wait for a advanced user to answer both questions :).
>
> Inf fact (if we could) the database engine deleting/updating option
> (using CASCADE for instance) would be the fastest way to do this.
>
> Greetings and sorry if my english is not too good plz, I'm from a
> spanish speaking country...
>
> On Apr 10, 12:45 pm, Mateusz Kaczanowski <kangu...@gmail.com> wrote:
>
> > Hi guys,
>
> > In CakePHP we delete related records by dependency in model. Which way us
> > better
>
> > 1. Set up CASCADE in innodb mysql database
> > 2. Usedependentin cakePHP model
>
> > "Better" - I mean faster , safer .
>
> > Thanks for answers

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