[eluser]macigniter[/eluser]
I got a question which I am sure was answered here before. But since the search function in this forum isn't that great *duck* I am asking it here:
Is there an easy way of detecting whether a dataset is related to any other table as defined in the models?
Let's say I have a "currencies" table with multiple rows:
1 USD
2 EUR
...
Now before I allow to delete a currency I would like to check if that currency is somewhere related in any of the other tables (e.g. prices, invoices, etc.). Since all relations are stored in the models I am sure there is an easier way of doing this:
$c = new Currency();
$c->get_by_name('USD');
if ( ! $c->price->count() && ! $c->invoice->count() && ...) $c->delete();
Something like $c->is_related() would be awesome. To check whether $c is related to any dataset in the related tables as defined in the models...