Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 30 days 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 (over 3 years ago)
- Default Branch: 2.x
- Last Pushed: 2024-06-16T23:29:38.000Z (5 months ago)
- Last Synced: 2024-09-29T14:41:43.405Z (about 1 month ago)
- Topics: database, hacktoberfest, mssql, mysql, php, postrgesql, sqlite
- Language: PHP
- Homepage:
- Size: 2.02 MB
- Stars: 54
- Watchers: 5
- Forks: 23
- Open Issues: 28
-
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
[![Latest Stable Version](https://poser.pugx.org/cycle/database/v/stable)](https://packagist.org/packages/cycle/database)
[![Build Status](https://github.com/cycle/database/workflows/build/badge.svg)](https://github.com/cycle/database/actions)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/cycle/database/badges/quality-score.png?b=2.x)](https://scrutinizer-ci.com/g/cycle/database/?branch=2.x)
[![Codecov](https://codecov.io/gh/cycle/database/branch/2.x/graph/badge.svg)](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).