Hi guys.

I'm having some trouble here regarding a project. I have a table with
projects, wich can be recursive (ie. sub-projects) and it is related to
itself.

By making the following query

---------------------8<--------------------------
SELECT * FROM projects LEFT JOIN projects proj_parent ON
projects.project_parent = proj_parent.parent_id WHERE project_id = 1234
---------------------8<--------------------------

i need to be able to access to the parent project's fields, but I have a
slight problem here.

First off, I have to make the LEFT JOIN. I don't know if the project can
be parent (therefore not finding a project_id = 0 wouldn't show the row)
and I need to add some kind of prefix to the proj_parent's fields so
that I can access them (or that they can't overwrite the project i'm
getting info on.

Well... there is an obvious sollution here: use an associative array
instead of an object, and access the properties by doing $array[0],
$array[1], etc. By my experience, this is a nightmare, maintenence-wise,
so I'd only use it as a _LAST_ resource.

Does anyone have any experience with this? The answer should be pretty
obvious, but I can't seem to figure it out :(

Thanks in advance.

André

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to