The application database is MySQL by default. One setting makes it SQLite: a single file, no server to install, which is all a small application or a test needs.
# apps/myapp/.env - read with padEnv, as every database setting is
padSqlDriver=sqlite
padSqlDatabase=myapp/myapp.sqlite # under DATA/
padSqlSetup=_install/schema.sql # builds it the first time
$padSqlDatabase is the file - a relative name lives under DATA/.
$padSqlSetup is optional: a .sql file in the application that is run
once, when the database file does not exist yet, so the first request builds the database
from text kept with the application.
Nothing else changes. The page below is one of the database examples, which this manual runs on MySQL - with the settings above it runs unchanged on SQLite:
|
PHP fragments/database_1.php |
HTML fragments/database_1.pad |
Result |
|---|---|---|
|
|
Jim's phone number is 555-4364 |
db() verbs answer in the same shapes - field, record,
array, check, insert with the new id,
update and delete with the rows they touched.{0} placeholders escape the way SQLite needs: a quote is doubled,
so a value never ends its literal early._data/*.sql queries and the Select subsystem work as
they do on MySQL.|| joins strings, a key is
integer PRIMARY KEY AUTOINCREMENT.