https://github.com/cycle/database
Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
https://github.com/cycle/database
database hacktoberfest mssql mysql php postrgesql sqlite
Last synced: about 2 months ago
JSON representation
Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
- Host: GitHub
- URL: https://github.com/cycle/database
- Owner: cycle
- License: mit
- Created: 2021-07-29T09:24:50.000Z (almost 4 years ago)
- Default Branch: 2.x
- Last Pushed: 2025-03-27T15:50:08.000Z (4 months ago)
- Last Synced: 2025-04-09T06:04:03.088Z (3 months ago)
- Topics: database, hacktoberfest, mssql, mysql, php, postrgesql, sqlite
- Language: PHP
- Homepage:
- Size: 3.52 MB
- Stars: 55
- Watchers: 4
- Forks: 26
- Open Issues: 29
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Cycle DBAL
[](https://packagist.org/packages/cycle/database)
[](https://github.com/cycle/database/actions)
[](https://scrutinizer-ci.com/g/cycle/database/?branch=2.x)
[](https://codecov.io/gh/cycle/database/)Secure, multiple SQL dialects (MySQL, PostgreSQL, SQLite, SQLServer), schema introspection, schema declaration, smart
identifier wrappers, database partitions, query builders, nested queries.## Documentation
* [Installation and Configuration](https://cycle-orm.dev/docs/database-configuration)
* [Access Database](https://cycle-orm.dev/docs/database-access)
* [Database Isolation](https://cycle-orm.dev/docs/database-isolation)
* [Query Builders](https://cycle-orm.dev/docs/database-query-builders)
* [Transactions](https://cycle-orm.dev/docs/database-transactions)
* [Schema Introspection](https://cycle-orm.dev/docs/database-introspection)
* [Schema Declaration](https://cycle-orm.dev/docs/database-declaration)
* [Migrations](https://cycle-orm.dev/docs/database-migrations)
* [Errata](https://cycle-orm.dev/docs/database-errata)## Requirements
Make sure that your server is configured with following PHP version and extensions:
* PHP 8.0+
* PDO Extension with desired database drivers## Installation
To install the component:
```bash
composer require cycle/database
```## Example
Given example demonstrates the connection to SQLite database, creation of table schema, data insertion and selection:
```php
[
'default' => ['connection' => 'sqlite'],
],
'connections' => [
'sqlite' => new Config\SQLiteDriverConfig(
connection: new Config\SQLite\FileConnectionConfig(
database: 'runtime/database.db'
),
),
],
]));$users = $dbm->database('default')->table('users');
// create or update table schema
$schema = $users->getSchema();
$schema->primary('id');
$schema->string('name');
$schema->datetime('created_at');
$schema->datetime('updated_at');
$schema->save();// insert data
$users->insertOne([
'name' => 'test',
'created_at' => new DateTimeImmutable(),
'updated_at' => new DateTimeImmutable(),
]);// select data
foreach ($users->select()->where(['name' => 'test']) as $u) {
print_r($u);
}
```## License:
MIT License (MIT). Please see [`LICENSE`](./LICENSE.md) for more information. Maintained
by [Spiral Scout](https://spiralscout.com).