Database Drivers
| Driver | DB_CONNECTION |
PHP extension |
|---|---|---|
| SQLite | sqlite |
pdo_sqlite |
| MySQL / MariaDB | mysql |
pdo_mysql |
| PostgreSQL | pgsql |
pdo_pgsql |
| SQL Server / Azure SQL | sqlsrv |
pdo_sqlsrv + Microsoft ODBC driver |
SQL differences (identifier quoting, upsert syntax, LIMIT / OFFSET, RETURNING, auto-increment types) are handled in
Query\Grammar and Schema\Schema, so your code does not change between drivers.
SQLite
Section titled “SQLite”The default. DB_DATABASE is a path relative to the project (default storage/database.sqlite) or :memory:. Foreign keys are
enabled for you. Good for development, tests and small deployments.
MySQL and MariaDB
Section titled “MySQL and MariaDB”DB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_DATABASE=myappDB_USERNAME=myappDB_PASSWORD=secretThe connection uses utf8mb4, real server-side prepared statements, and a strict SQL mode. MySQL implicitly commits DDL, so
migrations on MySQL are not wrapped in a transaction (they are on SQLite and PostgreSQL).
PostgreSQL
Section titled “PostgreSQL”DB_CONNECTION=pgsqlDB_HOST=127.0.0.1DB_DATABASE=myappDB_USERNAME=postgresDB_PASSWORD=secretSupports RETURNING, and migrations run inside a transaction.
SQL Server
Section titled “SQL Server”DB_CONNECTION=sqlsrvDB_HOST=sql.example.comDB_PORT=1433DB_DATABASE=myappDB_USERNAME=saDB_PASSWORD=secretDB_ENCRYPT=true # default: trueDB_TRUST_SERVER_CERTIFICATE=false # default: false; set true only for a self-signed dev serverRequires pdo_sqlsrv and the Microsoft ODBC driver. What the SQL Server dialect handles:
- identifiers are quoted with
[ ]; values withN'…' - pagination uses
OFFSET … FETCH(addingORDER BY (SELECT 0)when you did not order);limit(0)usesTOP (0) - upserts use
MERGE;IDENTITYcolumns;NVARCHAR,BITandDATETIME2column types ALTER TABLE … ADD(noCOLUMNkeyword) andDROPordering that removes foreign keys first formigrate:fresh- savepoints use
SAVE TRANSACTION/ROLLBACK TRANSACTION - bulk
insert/upsertare split into chunks that respect SQL Server’s limits (1000 rows, 2100 parameters) whereInwith more than 2000 values throws instead of failing at the databaseinsert($row, ignore: true)is not supported and throws
The connection string rejects values containing ;, { or }, so configuration cannot inject extra connection options.
Read-only replicas use ApplicationIntent=ReadOnly; see Read/write connections.
Adding a driver
Section titled “Adding a driver”Extend Query\Grammar and Schema\Schema for the new dialect and add a factory in DatabaseManager.