unframed / JSONModel.php

"People love ORMs"
GNU Lesser General Public License v3.0
28 stars 1 forks source link

Add a `references` option to models, use to cascade delete with MySQL #8

Open laurentszyster opened 9 years ago

laurentszyster commented 9 years ago

MySQL default engine does not support referential integrity.

However, MySQL extends the DELETE statement to support deleting in JOINed tables.

DELETE tasks, tags 
  FROM tags JOIN tasks
    ON tasks.task_id = tags.tag_task 
  WHERE 
    ... 

JSONModel cannot reconcile that difference between MySQL and other SQL databases.

So it must support both styles.

laurentszyster commented 9 years ago

Adding a references option to model is much better than adding a cascade option to its delete method.

We can use it in delete to eventually cascade when using MySQL.

And we may use it in relate to better define how model(s) are related.