SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: photo gallary

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2008
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    photo gallary

    Hi everyone

    I where wondering how would i go about storing photos for my users, i would allow them to save an unlimted amount in there gallarys, would i have save the filepath of each photo into an array then save that array to my phpmyadmin database?, i'm alitte unsure on the best method to do this.

    Thanks
    James

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If you're thinking of storing an array in a database, there are much better ways of doing this.

    What you should do is have a table for Users, a table for Galleries and a table for Pictures. The 'Galleries' table contains a field for the ID of the user creating it. The 'Pictures' table contains a field for the ID of the gallery it is in, and either a blob containing the file contents or a path to an image randomly named in a folder somewhere.

    You could then have a table for 'comments', with a field for the ID of the photo that the comment is referring to.

    The benefits for this kind of normalisation are countless. Firstly, you can get all kinds of data in a single query, for example to get the total amount of pictures that the user with user ID 10 has posted:
    Code sql:
    SELECT COUNT(Pictures.ID) AS PhotoCount FROM Pictures INNER JOIN Galleries ON Pictures.GalleryID = Galleries.ID AND Galleries.UserID = 10
    Secondly, it is more efficient - by far.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •