I occasionally need to code a small project in PHP, for which I usually prefer a local file database, so SQLite. However, it has often happened to me that I develop something on my local machine for one combo of sqlite+php versions; and when I upload on a server it doesn't work because there is a different versions combo there, which leads to me being quite frustrated.
Now, since I don't regularly use PHP, usually I cannot remember what the subtle differences between versions are. So I would like to ask someone knowledgeable to post runnable examples of, say, a following simple program:
- Create new database file on server disk
- Establish connection to database as necessary
- Insert one record in the database (something simple, e.g. 'id', 'name', 'account_num' being 1, 'Smith', 1000)
- Read the same record from the database (e.g. select id = 1), echo it
- Delete the record
- Delete database file from disk
... but in any applicable combination of:
- Php 4 vs. php 5 (and/or subversions of php 5.x if they introduce syntax incompatible with previous versions)
- Sqlite 2 vs. sqlite 3
- PDO vs non-PDO (AFAIK, PDO exists only for php 5, but I'm not sure)
Ideally, I'd like snippets which I could paste on a server, and see if they work there - besides generally reminding me of differences between syntaxes. Could anyone help? Link to an external resource that has similar kind of snippets would be very acceptable as well...
Aucun commentaire:
Enregistrer un commentaire