cycle / database
DBAL、模式自省、迁移和分页
2.11.0
2024-06-11 11:30 UTC
Requires
- php: >=8.0
- ext-pdo: *
- psr/log: 1 - 3
- spiral/core: ^2.8 || ^3.0
- spiral/pagination: ^2.8 || ^3.0
- symfony/polyfill-php83: ^1.28
Requires (Dev)
- ergebnis/composer-normalize: ^2.42
- infection/infection: ^0.26.10
- mockery/mockery: ^1.5
- phpunit/phpunit: ^9.5
- spiral/tokenizer: ^2.14 || ^3.0
- vimeo/psalm: ^5.18
Conflicts
- 2.x-dev
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.1
- 2.8.0
- 2.7.1
- 2.7.0
- 2.6.1
- 2.6.0
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- 1.x-dev
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-feat/automate-changelog
- dev-feat/infra-dx-v2
- dev-release-please--branches--feat/infra-dx-v2--components--database
- dev-feat/infra-dx
- dev-release-please--branches--feat/dx--components--database
- dev-feat/dx
- dev-feature/alias
- dev-hotfix/strict-type
- dev-driver-enhancments
- dev-feature/oracle
- dev-feature/oracle-support
This package is auto-updated.
Last update: 2024-09-11 12:02:30 UTC
README
安全、支持多种SQL方言(MySQL、PostgreSQL、SQLite、SQLServer)、模式自省、模式声明、智能标识符包装器、数据库分区、查询构建器、嵌套查询。
文档
需求
请确保您的服务器配置了以下PHP版本和扩展
- PHP 8.0+
- 包含所需数据库驱动程序的PDO扩展
安装
要安装组件
composer require cycle/database
示例
以下示例演示了与SQLite数据库的连接、创建表模式、数据插入和选择
<?php declare(strict_types=1); require_once "vendor/autoload.php"; use Cycle\Database\Config; use Cycle\Database\DatabaseManager; $dbm = new DatabaseManager(new Config\DatabaseConfig([ 'databases' => [ '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); }
许可证
MIT许可证(MIT)。有关更多信息,请参阅LICENSE
。由Spiral Scout维护。