I have the following data:
id parent_id
------------------ ------------------
Editor null
Printer Editor
TextWritingProggie Printer
LaTeX TextWritingProggie
OOfficeWriter TextWritingProggie
PhoneBook TextWritingProggie
I am querying for the PhoneBook id and all its parents. It should be a hierarchy that leads to the Editor as his parent is null and he is connected via the Printer which is connected via the TextWritingProggie which then is connected to the Phonebook.
I imagine that using SQL is more preferred however it might need to be handled via PHP.
Here's what Ive got so far but it stops after records that arent containing TextWritingProggie
SELECT * FROM acl_resources
WHERE id = 'TextWritingProggie' OR parent_id = 'TextWritingProggie'
ORDER BY COALESCE(parent_id, id), parent_id IS NOT NULL, id
Any help would be great