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.
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?
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.
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 :)