liberty_code / migration_model
库
Requires
- php: ~7 || ~8
- liberty_code/library: ^1.0.
- liberty_code/migration: ^1.0.
- liberty_code/model: ^1.0.
- liberty_code/sql: ^1.0.
- liberty_code/validation: ^1.0.
This package is auto-updated.
Last update: 2024-09-30 01:35:40 UTC
README
描述
该库包含迁移模型组件,用于管理应用程序迁移。
要求
- 脚本语言:PHP:版本 7 或 8
框架库实现要求
库仓库:liberty_code/validation:版本 1.0
标准规则实现(或等效)
在实体上提供的验证器,必须包含所有标准规则,添加在其规则集合中。
验证器规则实现(或等效)
在实体上提供的验证器,必须包含所有验证器规则,添加在其规则集合中。每个验证器规则必须使用验证器,其实现与实体上提供的验证器相同。
库仓库:liberty_code/sql:版本 1.0
验证 SQL 规则实现(或等效)
在实体上提供的验证器,必须包含所有 SQL 规则,添加在其规则集合中。
安装
有几种可能的方法
Composer
要求
它需要安装 composer。更多信息: https://getcomposer.org.cn
命令:在项目根路径下移动
cd "<project_root_path>"
命令:安装
php composer.phar require liberty_code/migration_model ["<version>"]
注意
包含供应商
如果项目使用 composer,则必须包含 vendor
require_once('<project_root_path>/vendor/autoload.php');
配置
安装命令允许在 composer 文件中添加
{ "require": { "liberty_code/migration_model": "<version>" } }
包含
下载
- 下载以下仓库。
- 将其放在仓库根路径上。
包含源代码
require_once('<repository_root_path>/include/Include.php');
使用方法
迁移
迁移实体系统允许设计迁移的数据结构,以在持久性中管理、检索和保存其数据。
元素
MigEntity
扩展了配置实体功能的保存。允许设计一个迁移实体并保存它。
MigEntityCollection
扩展了固定实体集合功能。允许设计迁移实体集合。
MigEntityFactory
扩展了固定实体工厂功能。允许设计迁移实体工厂,以提供迁移实体对象。
MigEntityRepository
扩展了固定多仓库功能。允许设计迁移实体仓库,以在持久性中保存从迁移实体中获取的数据。
MigEntityCollectionRepository
扩展了固定多集合仓库功能。允许设计迁移实体集合仓库,以在持久性中保存从迁移实体集合中获取的数据。
SqlMigEntity
扩展了迁移实体功能。使用 SQL 规则进行属性验证。
SqlMigEntityFactory
扩展了迁移实体工厂功能。提供 SQL 迁移实体对象。
SqlMigEntityRepository
扩展了迁移实体仓库功能。使用 SQL 表持久化器作为持久性。
SqlMigEntityCollectionRepository
扩展了迁移实体集合仓库功能。使用 SQL 表持久化器作为持久性。
// Get migration entity factory
use liberty_code\migration\entity\model\MigEntityFactory;
$migEntityFactory = new MigEntityFactory($provider);
...
// Get new migration entity
$migEntity = $migEntityFactory->getObjEntity();
...
构建器
构建器允许使用迁移实体集合和反之亦然来填充现有的迁移。
// Get migration entity collection
use liberty_code\migration\entity\model\MigEntityCollection;
$migEntityCollection = new MigEntityCollection();
...
// Get migration entity builder
use liberty_code\migration\entity\build\model\DefaultBuilder;
$migEntityBuilder = new DefaultBuilder($migEntityFactory);
...
// Hydrate migration entity collection
$migEntityBuilder->hydrateMigEntityCollection(
$migEntityCollection,
$migrationCollection
);
...
foreach($migEntityCollection->getTabKey() as $key) {
echo($migEntityCollection->getItem($key)->strAttrKey .'<br />');
}
/**
* Show:
* Migration key 1
* ...
* Migration key N
*/
...