Download the PHP package roolith/database without Composer
On this page you can find all versions of the php package roolith/database. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package database
roolith-database
PHP database driver
Supports MySQL, PostgreSQL (pgsql), and SQLite via PDO.
Any other PDO driver only works when you pass a raw DSN string directly.
Supported databases
| Driver | type value |
Connect example |
|---|---|---|
| MySQL | mysql (default) |
['type' => 'mysql', 'host' => 'localhost', 'port' => 3306, 'name' => 'dbname', 'user' => 'username', 'pass' => 'password'] |
| PostgreSQL | pgsql |
['type' => 'pgsql', 'host' => 'localhost', 'port' => 5432, 'name' => 'dbname', 'user' => 'username', 'pass' => 'password'] |
| SQLite | sqlite |
['type' => 'sqlite', 'name' => 'path/to/database.sqlite'] |
Raw PDO DSN strings are also passed through, for example $db->connect('sqlite::memory:');.
Install
Usage
Select
Note: condition is a trusted SQL literal escape hatch. Never interpolate input into it, pass variables via bindings.
Insert
Insert data when supplied email [email protected] not exists in table users:
Response:
Update
Note: array where only. Raw string where is unsupported to prevent injection.
update username if nobody else is using same username
Response:
Delete
Response:
Connect
or
Disconnect
Others
Search users table with LIKE operator
Get user by id 1
Pluck name and email from users table
Get total record of users table
Pagination
or
CLI / test safe pagination without $_GET / $_SERVER:
Transactions
transaction() commits on success, rolls back and rethrows on failure.
Nesting is unsupported.
Use inTransaction() when a helper may run inside or outside a transaction.
Return a value from the callback.
Throwing inside the callback triggers a rollback.
Manual commit and rollback.
Reusable helper that is safe in both contexts.
These all throw.
Bindings
Values are always bound, never interpolated:
Debug mode
Note: Once debug-mode is active queries are collected via getDebugLog() with no echo output!
Upgrade to 2.0
Breaking:
update()requires arraywhere(string where removed).delete()return shape dropsdebugkey.pageNumbers()ellipsis is'...'(was'.').new Paginateno longer reads$_GET/$_SERVER(usePaginate::fromGlobals()for legacy web orPaginate::fromRequest()).- New required interface methods (
buildConditionFragment, transactions, debug log,orderBy/limit/offset). - Requires
php >= 8.0.
Notes:
getDetails()returnsfrom=0,to=0past the last page.fromRequest()preserves query params minuspageParam.- Transactions reject nesting and stray
commit/rollBack(checkinTransaction()).
Development
Run tests:
Run coverage (needs phpdbg, no PCOV/Xdebug required):
All versions of database with dependencies
ext-pdo Version *