7940 Posts in 1543 Topics by 946 members
|Go to End|
20 October 2009 at 3:50am
I have a DataObjectManager for the agency website I am developing which associated many brands with a client. I have on the portfolio page a drop-down for brands, which uses DataObject::get to retrieve all Brands. However I have noticed that when removing a Brand under the CMS this does not remove it from the database, and hence it still appears in the drop-down.
One solution would be to convert the Brand objects to extend page, so I could at least check for a ParentID, but you still have a problem with unnecessary database bloat with items in there which should be deleted.
Is there a better way?
20 October 2009 at 4:21am
Deleting a record from the DOM should result in its removal from the database. I can't imagine why it wouldn't be executing that delete. Is that true for all of the objects you manage with DOM?
20 October 2009 at 4:33am
Further to this, the problem actually occurs when I delete a client page, without first going through and deleting the brands from that client i.e reduncant brand objects are left over. The following query seems to work:
$brands = Dataobject::get("Brand","","Name Asc","RIGHT JOIN ClientPage ON Brand.ClientID = ClientPage.ID"
Anyone know of a solution to all of the redundant data/columns in the database once you start to delete stuff without going into PHPMyadmin or similar?
20 October 2009 at 4:45am
You're expecting the deletion of a page to result in a cascade delete of objects related to it? It doesn't work that way. You haven't necessarily orphaned your Brand object by deleting the page that relates to it. The Brand record may get paired up with another ClientPage at some point. That relation is not one-to-one.
20 October 2009 at 9:44am
Thanks for clarifying. The thing is though, the Brand object could never get paired up again, because there isn't the option to associate current objects with a new Client Page using the DMA? Maybe my OO/SQL isn't the best
20 October 2009 at 10:09am
Then I would just use an onBeforeDelete() hook in your page class.
public function onBeforeDelete()
|Go to Top|