Download the PHP package solophp/database without Composer
On this page you can find all versions of the php package solophp/database. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package database
Solo Database
[!WARNING] Abandoned. This package is no longer maintained and gets no fixes. Use Doctrine DBAL instead, with solophp/repository for typed repositories. The current Solo packages are listed at solophp.github.io.
Lightweight and flexible PHP database wrapper with support for multiple database types, query building, and optional logging.
Installation
Features
- Support for MySQL, PostgreSQL, SQLite, SQL Server, and other PDO-compatible databases
- Safe query building with type-specific placeholders
- Flexible null value support, including for date parameters
- Configurable fetch modes (arrays or objects)
- Query preparation without execution
- Optional table prefixing
- Integration with PSR-3 compatible Solo Logger
- Transaction support
- Clean and flexible API with method chaining
Requirements
- PHP 8.2+
- PDO extension
- Solo Logger ^1.0
API Reference
| Method | Arguments | Description | Return Type |
|---|---|---|---|
query() |
string $sql, mixed ...$params |
Execute a query with placeholders | self |
prepare() |
string $sql, mixed ...$params |
Prepare SQL string without execution | string |
fetchAll() |
?int $fetchMode = null |
Fetch all rows | array<int|string, array|stdClass> |
fetch() |
?int $fetchMode = null |
Fetch single row | array|stdClass|null |
fetchColumn() |
int $columnIndex = 0 |
Fetch single column from next row | mixed |
lastInsertId() |
— | Get last inserted ID | string|false |
rowCount() |
— | Get number of affected rows | int |
beginTransaction() |
— | Begin transaction | void |
commit() |
— | Commit transaction | void |
rollBack() |
— | Roll back transaction | void |
inTransaction() |
— | Check if in transaction | bool |
withTransaction() |
callable $callback |
Run logic inside a safe transaction (auto rollback on exception) | mixed |
Query Placeholders
| Placeholder | Description |
|---|---|
?s |
String (safely quoted) |
?i |
Integer |
?f |
Float |
?a |
Array (for IN statements) |
?A |
Associative Array (for SET statements) |
?t |
Table name (with prefix) |
?c |
Column name (safely quoted) |
?d |
Date (DateTimeImmutable or null) |
?l |
LIKE condition with wildcards |
?M |
Multi-row INSERT (array of arrays) |
?r |
Raw parameter (unescaped) |
Usage
Basic Configuration
Query Examples
Database Support
Date formatting is handled automatically per driver:
- PostgreSQL:
Y-m-d H:i:s.u P - MySQL:
Y-m-d H:i:s - SQLite:
Y-m-d H:i:s - SQL Server:
Y-m-d H:i:s.u - DBLIB:
Y-m-d H:i:s - CUBRID:
Y-m-d H:i:s
Return Types
| Method | Description | Return Type |
|---|---|---|
fetchAll(?int $fetchMode = null) |
Get all rows | array<int|string, array|stdClass> |
fetch(?int $fetchMode = null) |
Get one row | array|stdClass|null |
fetchColumn(int $columnIndex = 0) |
Get column from next row | mixed |
rowCount() |
Affected rows from last query | int |
lastInsertId() |
Last inserted auto-increment ID | string|false |
Error Handling
- All database operations are wrapped in try-catch blocks
- Exceptions are thrown with meaningful messages
- Logging is automatic when PSR-3 logger is configured
- Transactions via
withTransaction()auto-rollback on failure
License
MIT License. See LICENSE file for details.
All versions of database with dependencies
PHP Build Version
Package Version
The package solophp/database contains the following files
Loading the files please wait ...