PHP Server-based variables/flags

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tromboneman
    New Member
    • Aug 2007
    • 7

    #1

    PHP Server-based variables/flags

    Hello!

    I have been working on a php script. In the script, fast reading/writing is necessary to a variable on the server side. It is a one bit flag. Right now, I have been using a text file to write the value 0 or 1 to it, but it isn't very efficient. I was wondering if there is a better way to do this other than the text file or a database. I don't want to add the extra requirement of a database to my program.

    Thanks a lot!
  • jx2
    New Member
    • Feb 2007
    • 228

    #2
    Originally posted by tromboneman
    Hello!
    It is a one bit flag. Right now, I have been using a text file to write the value 0 or 1 to it, but it isn't very efficient.
    Thanks a lot!
    you need to give as better idea on what you are trying to do

    normally you can store variables in the SESSION which automaticly save registered variables for you
    you can try to use mysql if you want to share it between a few users or serialize session

    ps: text files are very efficient thats just a data and it depends how u handle it

    all depends what you trying to achive

    regards
    jx2

    Comment

    • tromboneman
      New Member
      • Aug 2007
      • 7

      #3
      Thank you for your reply

      What I have done is created an AJAX-based application which sends off an int to the server. 0 queries the bit, 1 is set the bit to true, and 2 sets the bit to false. The bit is queried every 300 milliseconds by every client connected to the server. All of these clients need to have access to the same bit. So what I was wondering is if there is any way to do this other than through text files. Maybe there is something similar to a cookie on the server? I REALLY don't want to use a MySQL database, and it just seems like a waste to use a text file just for a 0 or 1.

      Thanks again!

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, tromboneman. Welcome to TSDN!

        If your server isn't storing the data SOMEWHERE on the hard drive, where is it going to store it? There is no mystical bit bucket floating over Silicon Valley; that's just the smog :)

        Of all your options, storing the value in a text file is actually the *most* efficient. It just also happens to be the least scalable.

        You could store the value in a database (which gets saved into a file on the hard drive).

        Or you could store the value in $_SESSION (which gets saved into... a file on the hard drive!).

        Comment

        • tromboneman
          New Member
          • Aug 2007
          • 7

          #5
          Okay, thank you. I just assumed there would be a way to store temporary variables in memory. Thank you for your help!

          Comment

          Working...