cross checking tables?

24 views
Skip to first unread message

Craig

unread,
May 11, 2012, 11:52:01 AM5/11/12
to joomla-de...@googlegroups.com
I would like to make sure the data being saved refers to an item whose parent owns it. Basically:

TableA
id
child_id
parent_id

TableChild
id
parent_id

TableParent
id
user_id

TableA may have neither child_id nor parent_id, parent_id and not child_id, or both ids. 

In the model for my A entity, I tried to pull up the models for my child and parent entities so I could call methods to check ownership, but getModel isn't available from within a model? If there is some way to get another model from within a model, this would solve my problem. 

Another approach would be to write and use the check() method on JTables for the parent and child. However, for the child check, I would need to refer to the parent table to check ownership. How would I do that - can I get a JTable from within another JTable? I know I can fall back to writing SQL and querying, but that seems a little ugly from within JTable. 

... or is there a much simpler way to handle this?


Craig

unread,
May 14, 2012, 8:48:34 AM5/14/12
to joomla-de...@googlegroups.com
Is this type of foreign key checking not usually done in Joomla components? 

Michael Conte

unread,
May 14, 2012, 9:01:09 AM5/14/12
to joomla-de...@googlegroups.com

I don't see any reason to have achild I'd, you just check for the child's patent Id. As for database querys, idk if there a special joomla thinks I use PHP, ill post code when I get home

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/pbcuPvryhFgJ.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
Reply all
Reply to author
Forward
0 new messages