dongyuan1983 2012-05-30 13:45
浏览 33
已采纳

PHP层次结构/图库系统

I'm in the process of writing my own simple gallery script in OOP (still learning) PHP.

I'm trying to pull the albums from the database in the most efficient way as the current gallery script (Gallery2) is extremely resource heavy, this will be replacing it. The current gallery has roughly 35,000 items and roughly 100 albums.

album layout
(source: iforce.co.nz)

As you can see with the above image I require unlimited sub albums (in reality probably only 5-6 max).

Database layout is pretty simple as all it needs to do is display the images.

albums table album_id (int/auto_increment) album_parent (int) album_name (tingtext)

items table item_id (int/auto_increment) item_album (int) item_name (int)

Few queries I've came up with have just been based off using a WHERE statement and going off the parent album ID eg..

parent ID 0 = top level parent ID 3 would grab all albums that are parented to that ID.

The problem I have is that I would like to build the breadcrumbs and URLs using the albums (album_1/subalbum_1/etc) names and subalbums, using the current query I cannot pull them all at once.

Unless I'm overlooking something the URL would need to be like script.php?album_id=1&album_id=3&album_id=6 that would grab them as if 1 was top level, 3 was sub, and 6 was a sub of 3.

I have read a lot of articles regarding a hierarchy setup but most are directed towards tree hierarchy layout, I don't need to display all album's sub albums at once for every album more towards a single path hierarchy.

Thanks

edit I thought I should point out that the album names can be named anything, the dates were only used for naming not actual timestamps etc. Sorry

  • 写回答

3条回答 默认 最新

  • douiwn6941 2012-05-30 13:57
    关注

    Retrieve path as ianhales suggested but store it into database table, and retrieve from there to display.

    So store current node path into table, and only when moving, renaming nodes will need updating path.

    This way will be more efficient reads.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式