Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default File Operations

    I am writing a project in PHP for Unix based systems and may need to
    store data in files as apposed to an SQL server, I know there are many
    problems that can arise out of using files in this way especially when
    multiple users are concerned and would prefer not to use them at all,
    but if I have to I could do with some suggestions about the best way to
    avoid trashed files due to simultaneous writes.

    I am aware of the flock() function and ignore_user_abort() but aren't
    sure of the best way to implement them, and I also hear that
    ignore_user_abort() doesn't work when PHP is running in safe mode.

    Thanks for any help you can give.

    ~Cameron

    Cameron Guest

  2. Similar Questions and Discussions

    1. File Operations and System Calls in Perl (WAS: some doubt)
      Okay, I'll give you a few pointers, but first, please use a more descriptive subject line and start a new message when you start a new thread. ...
    2. #26375 [NEW]: Circumventing safe mode to extend file operations
      From: php-online at cyberblue dot org dot uk Operating system: MacOS/Redhat PHP version: 4.3.3 PHP Bug Type: Feature/Change...
    3. advice on file operations
      My project shows QuickTime short movies of people being interviewed. Its going to be on DVD but I need to store information such as, bookmarked...
    4. Why two POST Operations?
      Hello, This is perhaps a bit of a newbie question, but I am using the Apache Axis tcpmon program to inspect xml-based web services messages with...
    5. Database Operations
      After creating a data source to a database in DMX is it possible to create database tables, add/edit table fields, etc.
  3. #2

    Default Re: File Operations

    Cameron <devnull@foo-bar.invalid> writes:
    > I am writing a project in PHP for Unix based systems and may need to
    > store data in files as apposed to an SQL server, I know there are many
    > problems that can arise out of using files in this way especially when
    > multiple users are concerned and would prefer not to use them at all,
    > but if I have to I could do with some suggestions about the best way to
    > avoid trashed files due to simultaneous writes.
    >
    > I am aware of the flock() function and ignore_user_abort() but aren't
    I haven't used flock in a while as I too go RDBMS whenever possible.

    However, flock is usually adequate to avoid multiple file access. Use
    it in a similar way as a DB transaction block.

    open file
    exclusive lock (you can either block here or spinn and retry)
    read file
    write file
    release lock
    close file

    HTH



    --
    -------------------------------------------------------------------------------
    Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant
    305 321-1144 (mobile [url]http://www.JerrySievers.com/[/url]
    Jerry Sievers Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139