If you receive an error while trying to write to a sqlite database (update, delete, drop):
Warning: PDO::query() [function.query]: SQLSTATE[HY000]: General error: 1 unable to open database
The folder that houses the database file must be writeable.
PDO_SQLITE, PHP Veri Nesneleri Arayüzünün (PDO) SQLite 3 veritabanlarına erişimini mümkün kılmak için gerçeklenmiş bir sürücüdür.
Bilginize:
PDO_SQLITE dizgelerin akımlardan ayrı olarak
PDO::PARAM_LOB
ile birlikte kullanımını mümkün kılar.
The PDO_SQLITE PDO driver is enabled by default. To disable,
--without-pdo-sqlite[=DIR] may be used,
where the optional [=DIR]
is the sqlite base install directory.
As of PHP 7.4.0 » libsqlite ≥ 3.5.0 is required.
Formerly, the bundled libsqlite could have been used instead, and was the
default, if [=DIR]
has been omitted.
Bilginize: Additional setup on Windows as of PHP 7.4.0
Bu eklentinin çalışabilmesi için bazı DLL dosyalarının bulunduğu yerlerin Windows sistem PATH'ında tanımlı olması gerekir. Bunun nasıl yapılacağı SSS altında "PHP dizinimi Windows'ta PATH'a nasıl eklerim" başlığı altında açıklanmıştır. Eklenti, DLL dosyaları PHP dizininden Windows system dizinine taşındığında da çalışırsa da (çünkü system dizini sistem PATH'ında zaten vardır) bu önerilmez. Bu eklentinin çalışabilmesi için bulunduğu dizine PATH üzerinden erişebilmesi gereken dosyanın ismi: libsqlite3.dll.
If you receive an error while trying to write to a sqlite database (update, delete, drop):
Warning: PDO::query() [function.query]: SQLSTATE[HY000]: General error: 1 unable to open database
The folder that houses the database file must be writeable.
Instead of compiling an old version of SQLite to create a database using an older database format that the version of SQLite bundled with PDO can handle, you can (much more easily) just run the query "PRAGMA legacy_file_format = TRUE;" BEFORE creating the database (if you have an existing database, run ".dump" from the sqlite shell on your database, run the sqlite shell on a new database, run the PRAGMA, then paste the contents of the .dump). That will ensure SQLite creates a database readable by SQLite 3.0 and later.
With PDO SQLite driver, calculation within an SQL with multiple ? may not get results as you expect.
<?php
// ....
$stmt = $PDO->prepare('SELECT * FROM `X` WHERE `TimeUpdated`+?>?');
$stmt->execute([3600, time()]);
$data = $stmt->fetchAll();
print_r($data);
?>
To get the right results, you have more than 3 solutions.
1. Change 'SELECT * FROM `X` WHERE `TimeUpdated`+?>?' to 'SELECT * FROM `X` WHERE `TimeUpdated`>?' and do the math using Php (ie: $stmt->execute([time()-3600]); ).
2. Use PdoStatement::bindParam or PdoStatement::bindValue, and set the parameter type to PDO::PARAM_INT.
3. Change 'SELECT * FROM `X` WHERE `TimeUpdated`+?>?' to 'SELECT * FROM `X` WHERE `TimeUpdated`+?>?+0', here '?+0' may be replaced by another math function or another calculation, such as 'abs(?)', you can even wrap both ? with a math calculation.
Note that as of the date of this post, PDO_SQLITE will not interact with database files created with the current version of the SQLite console application, sqlite-3.3.6.
It is currently necessary to obtain version 3.2.8, available from http://www.sqlite.org/ but only by entering the URI manually, as there is no link. Go to http://www.sqlite.org/download.html and find the URI of the version you're looking for, then make the appropriate version number substitution.