On 6 Apr 2017, at 7:38pm, dave boland <dbola...@fastmail.fm> wrote:

> "unconfigured means no tables, no fields, no nothing.  With SQLite, it
> is possible to have an empty file, a database with a table but no
> fields, etc.  The reason this concerns me is that I want to know what I
> have before connecting to a file and creating a new database when I did
> not intend to do that.  So, what (and why) are the steps to test the
> database file to see what state it is in?

Okay.  If that’s the definition of 'unconfigured' you want, do what I 
recommended in a previous post:

First, use the PHP function "file_exists()" to check that the file exists.

If the file does exist use PHP to check it’s an actual database:

fopen(path, 'rb')
fread(, 16)
fclose().

Then check those 16 bytes.  They should be 'SQLite format 3\0'.  The last 
character is a 0x00 byte for a string terminator.  If there are less then 16 
bytes, or if they don’t match that string then it’s not a "configured" (by your 
definition) SQLite database.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to