spiral / database
DBAL, schema introspection, migration and pagination
Installs: 74 176
Dependents: 9
Suggesters: 0
Security: 0
Stars: 33
Watchers: 4
Forks: 11
Open Issues: 13
Requires
- php: >=7.2
- ext-pdo: *
- spiral/core: ^2.7
- spiral/logger: ^2.7
- spiral/pagination: ^2.7
Requires (Dev)
- mockery/mockery: ^1.1
- phpunit/phpunit: ~8.0
- spiral/code-style: ^1.0
- spiral/dumper: ^2.7
- spiral/tokenizer: ^2.7
- dev-master
- v2.8.0
- v2.7.21
- v2.7.20
- v2.7.19
- v2.7.18
- v2.7.17
- v2.7.16
- v2.7.15
- v2.7.14
- v2.7.12
- v2.7.11
- v2.7.10
- v2.7.9
- v2.7.8
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.10
- v2.6.9
- v2.6.8
- v2.6.7
- v2.6.6
- v2.6.5
- v2.6.4
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.1
- v2.5.0
- v2.4.5
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.1
- v2.3.0
- v2.2.5
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.2
- v2.0.1
- v2.0.0
- 1.0.x-dev
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.2
- v1.0.1
- v1.0.0
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9.0
- dev-fix_postgresql_duplicated_queries
This package is auto-updated.
Last update: 2020-12-23 19:15:19 UTC
README
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
- Access Database
- Database Isolation
- Query Builders
- Transactions
- Schema Introspection
- Schema Declaration
- Migrations
- Errata
Requirements
Make sure that your server is configured with following PHP version and extensions:
- PHP 7.2+
- PDO Extension with desired database drivers
Installation
To install the component:
$ composer require spiral/database
Example
Given example demonstrates the connection to SQLite database, creation of table schema, data insertion and selection:
<?php declare(strict_types=1); require_once "vendor/autoload.php"; use Spiral\Database\Config\DatabaseConfig; use Spiral\Database\DatabaseManager; use Spiral\Database\Driver\SQLite\SQLiteDriver; $dbm = new DatabaseManager(new DatabaseConfig([ 'databases' => [ 'default' => ['connection' => 'sqlite'], ], 'connections' => [ 'sqlite' => [ 'driver' => SQLiteDriver::class, 'connection' => 'sqlite: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
for more information. Maintained by Spiral Scout.