2008年10月17日星期五

Re: [fw-db] Re: Re[fw-db] ferencemap: delete CASCADE

On Oct 17, 2008, at 7:41 AM, monk.e.boy wrote:

I just stepped through the code and Row->delete calls cascadeDelete, but
when this runs it calls Db->delete for each child table. Db->delete does
_NOT_ call cascadeDelete :-(

So this only cascades one level deep as far as I can tell. Weird. You'd
imagine it'd be recursive?!

Right, it only goes one level down in the current implementation.  Truth be told, I regret that it does even that much.  Cascading operations should be handled by the database engine, because they are not atomic when they are run from the client.  

If you want cascading operations, then you should use a storage engine that supports these operations in the database.  This means you shouldn't use MyISAM for cascading operations.

Sorry to reply to myself, but in the $_referenceMap, what do the rule names
mean? I just use random names... is this my problem?

Yes, the rule names are an arbitrary string.  It's meant to allow you to define something mnemonic.  This rule name is useful if you have multiple foreign keys to the same table, and you want to specify which one when you do a lookup.  

There are examples in the documentation, e.g.:

  $bug->findParentAccountsByEngineer();

Where 'Engineer' is the rule name.

Regards,
Bill Karwin

没有评论: