On Wed, 24 Nov 2004, Alexander Jordanov wrote:
@Ara.T.Howard: Thanks for the suggestion i will try it and hope the database will not lock again... Here is what i did: clearstatcache (); if ($sql[0]=='S'){ $fp=fopen('koral.db.lock','a+'); while (!flock($fp,LOCK_SH)){}; } else { $fp=fopen('koral.db.lock','a+'); while (!flock($fp,LOCK_EX)){}; } $result = sqlite_query($this->handle, $sql); flock($fp,LOCK_UN); fclose($fp); Please tell me if that is what you meant. My database file is koral.db. This is a part of a class file i use to run the queries $this->handle is the handle returned by sqlite_open('koral.db',0666,$sqliteerror). koral.db.lock is empty i don't write or read from it just check if it's locked or not and according to that determine what i can do. $sql is the query that will run and i check if it's first letter is S from SELECT and if it is i do a shared lock if not Exclusive lock. Thank you for the help.
yes - sounds resonable if 100% of your access is through this class. my code is very similar. my class forces the user to specify whether the transaction is write or read and issued the appropriate sql and aquires the corresponding lock (LOCK_SH, LOCK_EX). in this way i don't need to check for 'S' etc. which is a bit fragile. in any case you've got the idea. btw. flock is not safe on nfs filesystems.
sorry i was out when you replied and hope your problem is fixed..
regards.
-a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================