diff --git a/reference/dba/functions/dba-open.xml b/reference/dba/functions/dba-open.xml index 996ace670f..e0e63a6ea8 100644 --- a/reference/dba/functions/dba-open.xml +++ b/reference/dba/functions/dba-open.xml @@ -1,5 +1,5 @@ - + @@ -27,7 +27,11 @@ mode is "r" for read access, "w" for read/write access to an already existing database, "c" for read/write access and database creation if it doesn't currently exist, and "n" for - create, truncate and read/write access. + create, truncate and read/write access. Additional you can use "l" to + lock the database with an .lck file or "d" to lock the databasefile itself. + It is important that all of your applications do this consistently. If + you want to test the access and do not want to wait for the lock you can + add "t". handler is the name @@ -44,10 +48,98 @@ There can only be one writer for one database file. When you use dba on a webserver and more than one request requires write operations they can - only be done one after another. Unfortuanetly some of the external - libraries simply fail or ignore this when trying to open the database for - another write operation. In this case you must use semaphores to guard - against. See System V semaphore support. + only be done one after another. Also read during write is not allowed. + The dba extension uses locks to prevent this. See the follwoing table: + + DBA locking + + + + already open + mode = "rl" + mode = "rlt" + mode = "wl" + mode = "wlt" + mode = "rd" + mode = "rdt" + mode = "wd" + mode = "wdt" + + + + + not open + ok + ok + ok + ok + ok + ok + ok + ok + + + mode = "rl" + ok + ok + wait + false + illegal + illegal + illegal + illegal + + + mode = "wl" + wait + false + wait + false + illegal + illegal + illegal + illegal + + + mode = "rd" + illegal + illegal + illegal + illegal + ok + ok + wait + false + + + mode = "wd" + illegal + illegal + illegal + illegal + wait + false + wait + false + + + +
+ + ok: the second call will be successfull. + wait: the second call waits until dba_close is called for the first. + false: the second call returns false. + illegal: you must not mix "l" and "d" modifiers for mode parameter. + +
+ + + + Locking and the mode modifiers "l", "d" and "t" were + added in PHP 4.3.0. + In PHP versions before PHP 4.3.0 you must use semaphores to guard against + simultanious database access for any database handler with the exception of + GDBM. See System V semaphore support.