| View previous topic :: View next topic |
| Author |
Message |
lizciz
Joined: 19 Mar 2008 Posts: 10
|
Posted: Thu Jun 05, 2008 10:04 pm Post subject: DB_Table_Database cascading delete |
|
|
Hi
I'm having trouble with the cascading delete feature of the DB_Table_Database package, the problem being that it doesn't work
I use the auto generated Database.php file. In it I add a reference like so
| Code: |
$db->addRef('ImageSet', 'ImageSetID', 'Kittens', null, 'cascade', 'restrict');
|
Upon deleting a row from 'Kittens', nothing happens with 'ImageSet'. I tried switching 'cascade' to 'restrict' and correctly got an error saying I'm not allowed to delete the row. But 'cascade' does nothing.
Any idea of what could be the problem?
Thanks
lizciz |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1013
|
Posted: Sat Jun 07, 2008 2:02 pm Post subject: |
|
|
This might be a bug, and I'd like to verify/analyze the behaviour.
Would it be possible to get a SQL dump of the two (?) tables and the generated (or modified) PHP scripts? Or at least the scripts without a dump?
My email address is wiesemann(at)php(dot)net, thanks. |
|
| Back to top |
|
 |
lizciz
Joined: 19 Mar 2008 Posts: 10
|
Posted: Sat Jun 07, 2008 9:04 pm Post subject: |
|
|
| Sure. I don't really know what you mean with a SQL dump, but I will supply you with the files. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1013
|
Posted: Sat Jun 07, 2008 9:58 pm Post subject: |
|
|
Thanks for your email, I'll try to take a look at the problem soon.
About "SQL dump": please read yourself => http://en.wikipedia.org/wiki/Database_dump
Anyway, the files that you've sent should be enough. |
|
| Back to top |
|
 |
lizciz
Joined: 19 Mar 2008 Posts: 10
|
Posted: Sun Jun 08, 2008 1:41 am Post subject: |
|
|
Aha, I knew what it was, just didnt know what it was called Thanks for the link though.
Anyway, I doupt a dump would be of any use to you, since I'm still developing the site and each table has got only two or three rows, with an ID connecting them.
I hope you can make sense of it all, and that I'll hear from you soon  |
|
| Back to top |
|
 |
lizciz
Joined: 19 Mar 2008 Posts: 10
|
Posted: Tue Jun 10, 2008 12:09 pm Post subject: |
|
|
This issue has been solved. Just for the record, here is the solution.
The addRef() function can have it's fourth parameter set to null if it is the same as the seccond (if the IDs are the same). However, if it is set to null DB_Table uses the tables primary key and in my case, this was not the wanted behaviour, as 'ImageSetID' wasn't the primary key of the table 'Kittens'. This resultet in the cascading delete to work only if the two IDs had the same values.
The fix was to specify the fourth parameter properly, as shown below.
| Code: |
$db->addRef('ImageSet', 'ImageSetID', 'Kittens', 'ImageSetID', 'cascade', 'restrict');
|
|
|
| Back to top |
|
 |
|