The Titon Database package provides a lightweight and low-level interface for interacting with database engines (known as drivers). The DB package comes bundled with a robust database abstraction layer (DBAL), an object oriented query builder, a powerful SQL dialect formatter, a data type caster, custom finder classes, behaviors, mappers, schemas, and many more.
$db = Titon\Db\Database::registry();
$db->addDriver('default', new Titon\Db\Mysql\MysqlDriver([
'user' => 'root',
'pass' => 'pass'
]));
$users = new Titon\Db\Repository(['table' => 'users']);
$entities = $users->select()->where('status', 1)->orderBy('created_at', 'desc')->all();
Supported database engines are packaged as individual driver packages, which are listed below.
MySQL
- https://github.com/titon/db-mysqlPostgreSQL
- https://github.com/titon/db-postgresqlSQLite
- https://github.com/titon/db-sqliteMongoDB
- https://github.com/titon/db-mongodb
Database
- Driver managerRepository
- Table representation, queries drivers, maps relations and returns entitiesBehavior
- Executes logic during database eventsEntity
- Single record of dataEntityCollection
- Collection of entitiesFinder
- Select query formattingDriver
- Interacts with a database or remote serviceDialect
- Driver specific SQL formattingSchema
- Repository schemaType
- Data type mappingResultSet
- Result set mapper
Query
- Object oriented query builderRawExpr
- Raw expression builderExpr
- Expression builderFunc
- Function builderJoin
- Join builderPredicate
- Clause builder
Common
Event
Type
Cache
(optional)Psr\Log
(optional)
- PHP 5.4.0
- PDO