| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#3 (permalink) |
|
Skittles
Super #1
|
Sorry that nobody responded here. I'm glad you were able to find a way to work around this. If you have questions like this in the future, be sure to send in a ticket, we will be happy to help! 24x7 Fast, Reliable Support by Surpass Hosting
|
|
|
|
|
|
#4 (permalink) | |
|
minor deity
Super #1
Joined in Apr 2004
Lives in Georgia
Hosted on XEON, Pass60, Pass61
7,692 posts
Gave thanks: 49
Thanked 111 times
|
Quote:
__________________
Proud to be a Surmunity Mod! XEON Make a fundamental difference! My Sites: Curious about Brewing Beer? Join the community! >>>>> Some Change is GOOD! Keep your paycheck! Support the Fair Tax Get into an Art museum Victorian London It's your brain -ON WEB - mybrainhost.com (under development) What SHOULD Government do? Much Less than it Does! |
|
|
|
|
|
|
#6 (permalink) |
|
Surpass FTW
Seasoned Poster
|
Well, I take that back. You may need privileges added to the user to create routines, or stored procedures. I know you are going to need explicit access given to execute them as well. I remember that now
If you ever need stored procedure access, submit a ticket.
__________________
Kenneth H. Support Supervisor |
|
|
|
|
|
#7 (permalink) | |
|
Registered User
Fresh Surpasser
Joined in Jun 2004
14 posts
Gave thanks: 0
Thanked 0 times
|
Quote:
I was intending on using a stored procedure with a temporary table to retrieve hierarchical data using the method of each row having an id and a parent_id. I was going to loop through building the hierarchy the way I normally do with MS SQL Server. I got around it by keeping an extra field to store the "lineage" of the row: "parent-parent-parent-currentID" if the item was 4 levels deep, etc.. Made my code a bit more complicated and had some limitations but will probably end up making things run faster in the long run so worked out in the end. ![]() |
|
|
|
|
|
|
#8 (permalink) |
|
Surpass FTW
Seasoned Poster
|
Ahhh.. Hierarchical data. That's fun
. I just had to do a site for somebody where I needed to use hierarchical data. The only issue was, there was no set max depth what-so-ever. Came up with a "tree" of sorts thanks to a post I found online somewhere, where the table was set up like the following:id name left right All children would be held within left and right of it's parent, so after one insertion, it would be: 1 Electronics 0 1 After another insert, it would be: 1 Electronics 0 3 2 TVs 1 2 If we wanted to do a children of TVs, it would be: 1 Electronics 0 5 2 TVs 1 4 3 Plasma 2 3 And so on. I thought it was a pretty good solution. If you need any more help please let us know ![]()
__________________
Kenneth H. Support Supervisor |
|
|
|
|
|
#9 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Jun 2004
14 posts
Gave thanks: 0
Thanked 0 times
|
Ooof. The nested sets model. Read a lot about it and follow the concept. It just makes my brain hurt thinking about it.
What I normally do is use a parent child relationship where each row has, for example, a field called item_id and one called parent_item_id. item_id is a system generated one up number. parent_item_id points to its parent or is null (or zero if that's easier) if it doesn't have a parent and is at the top of its tree. This makes entering data and looking at it in the database pretty easy but retrieving it in a hierarchical manner a bit more tricky. We use a variation of the stored procedure below to pull out the hierarchical data:Code:
CREATE PROCEDURE HierList(@current int) as
set nocount on
declare @lev int
create table #stack (item_id int,item_nm varchar(50), lev int)
create table #stackout (item_id int, item_nm varchar(50), lev int)
insert #stack
select @current, item_nm, 1
from item
where item_id = @current
select @lev = 1
while @lev > 0
begin
if exists (select * from #stack where level = @lev)
begin
select @current = item_id
from #stack
where lev = @lev
order by item_nm desc
insert #stackout
select item_id, item_nm, lev
from #stack
where item_id = @current and lev = @lev
delete from #stack
where item_id = @current and lev = @lev
insert #stack
select item_id, space((@lev * 2) - 1) + item_nm, @lev +1
from item
where parent_item_id = @current
if @@ROWCOUNT > 0
select @lev = @lev + 1
end
else
begin
select @lev = @lev - 1
end
end
select * from #stackout
Don't get me wront, I'm not knocking the nested sets model. It's probably superior to the method we use. It just makes my brain hurt when I'm looking at data where their are multiple places where the hierarchy starts (no parent) that go 8 or more levels deep. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|