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条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP