Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "global" session for all users

    I'm working on a multilingual site. All texts in all languages are saved in a database. This means that for each page a user enters the database must be accessed to fetch the texts for the page. This is choking the database.

    So what I need, ideally, is to put all the text from the database into memory where all users can access it. Some sort of global or common session for all users.

    Can this be done in PHP??

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    PHP does not have `application scope variables` in the same way that ASP does. Application scope variables are in essence (in ASP) a glorified text file which is how you would normally emulate such in PHP ... or use a database which is obviously already causing you problems.

    You can allocate shared memory BUT if you are having issues with the database already this is not a good plan.

    I would suggest that some form of caching is the answer, be that caching language files for inclusion at runtime or caching whole pages where possible.

    Its hard to make too many suggestions without knowing a little more about your application and how much data (that needs to be translated) is dynamic and how much is relatively static ? , are we talking say a few sets of navigation links or whole tracts of information ? and how often does this data change ?

    say your pages were mostly static then I would suggest apache's content negotiation and static pages .. tell us more
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think we indeed need to have more info.

    But i can hardly believe that dynamically building the pages is choking the db. You'll probably just need a handfull of records for each page. If you create an index on the column with the 'language' in it (--> needs to be a numerical column, so a foreign key of your actual language-table) and you create another index on the column with the page ID (--> again a numerical columntype that holds the FK to the page-table) then selecting the required records will go real fast. Even if you would have 100 different languages And the total volume of the recordsets will be rather small (or else you need to rethink your pages --> people don't reed that much text on a webpage ...) since it's only the text and not the images and so.

    Maybe doing some rearanges in your db or pageflow will be enough to solve this.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by firepages
    PHP does not have `application scope variables` in the same way that ASP does. Application scope variables are in essence (in ASP) a glorified text file which is how you would normally emulate such in PHP ... or use a database which is obviously already causing you problems.

    You can allocate shared memory BUT if you are having issues with the database already this is not a good plan.

    I would suggest that some form of caching is the answer, be that caching language files for inclusion at runtime or caching whole pages where possible.

    Its hard to make too many suggestions without knowing a little more about your application and how much data (that needs to be translated) is dynamic and how much is relatively static ? , are we talking say a few sets of navigation links or whole tracts of information ? and how often does this data change ?

    say your pages were mostly static then I would suggest apache's content negotiation and static pages .. tell us more
    Well, yes... Application objects, like in ASP, is what I'm after.

    If that's not possible in PHP I guess the only way is to save the content in db to "language"-files, and modify each PHP-file file to read from this file(s).

    Caching is not an option in this regard because the application is fetching text strings depending on what the user does. Say the user made a mistake when entering some data, the application fetches the string from the db displaying the error message to the user. So caching will not be impossible.

    But what were you saying about allocating shared memory??

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't think you understand the function and use of the application-object inside ASP.

    This object needs to contain only data that is identical for all clients. Like the number of visitors, the number of seconds to 2005, the highest bid inside an auction.

    You need exactly the oposit : clientspecific data. Or more accurate, language specific data you can select on for that specific client.

    Using the applicationobject to store all content in would not be a good idea, because db's far are better equiped to search and filter on. In fact, tey are exactly build and optimized for operations like dynamically generating pages.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    Quote Originally Posted by Pompiuses
    But what were you saying about allocating shared memory??
    ...well you can utilise shared memory (shmop functions) but it is only realistic for very small amounts of data , not even close to realistic for your purposes.

    Methinks along the lines of Raf's post that perhaps a rethink of your DB structure may solve some of these issues.

    remember that the application objects (in ASP.OLD at least) were no more than text files , text-files used this way can be useful in a `write-once read-many times` situation , else a DB really is the way to go.

    How are your tables indexed ? I have seen the addition of a couple of indexes turn a 'go and have a cuppa while this runs' routine into a 'g..' ah done routines , the performance difference between well indexed tables and badly indexed ones can be amazing.

    The other possibility of course is the database configuration itself .. thats another story though.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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