fyre / schema
数据库模式库。
v4.2.4
2024-08-20 11:43 UTC
Requires
- fyre/cache: ^3.0
- fyre/db: ^4.0
- fyre/typeparser: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- fyre/php-cs-fixer-config: ^1.0
- phpunit/phpunit: ^10
README
FyreSchema 是一个免费、开源的 PHP 数据库模式库。
目录
安装
使用 Composer
composer require fyre/schema
在 PHP 中
use Fyre\Schema\SchemaRegistry;
模式注册表
获取缓存
获取 缓存器。
$cache = SchemaRegistry::getCache();
获取模式
$connection
是一个 连接。
$schema = SchemaRegistry::getSchema($connection);
设置缓存
设置 缓存器。
$cache
是一个 缓存器。
SchemaRegistry::getCache($cache);
设置处理器
SchemaRegistry::setHandler($connectionClass, $schemaClass);
模式
清除
从缓存中清除数据。
$schema->clear();
描述
获取表的 TableSchema。
$name
是代表表名的字符串。
$tableSchema = $schema->describe($name);
获取连接
获取 连接。
$connection = $schema->getConnection();
获取数据库名
获取数据库名。
$database = $schema->getDatabaseName();
有表
确定模式是否有表。
$name
是代表表名的字符串。
$hasTable = $schema->hasTable($name);
表
获取表的全部数据。
$name
是代表表名的字符串。
$table = $schema->table($name);
表名
获取所有模式表的名称。
$tableNames = $schema->tableNames();
所有表
获取所有模式表的数据。
$tables = $schema->tables();
表格模式
清除
从缓存中清除数据。
$tableSchema->clear();
列
获取表列的数据。
$name
是代表列名的字符串。
$column = $tableSchema->column($name);
列名
获取所有表列的名称。
$columnNames = $tableSchema->columnNames();
所有列
获取所有表列的数据。
$columns = $tableSchema->columns();
默认值
获取列的默认值。
$name
是代表列名的字符串。
$defaultValue = $tableSchema->defaultValue($name);
此方法将评估表达式值(例如 current_timestamp())。
外键
获取表外键的数据。
$name
是代表外键名称的字符串。
$foreignKey = $tableSchema->foreignKey($name);
外键
获取所有表外键的数据。
$foreignKeys = $tableSchema->foreignKeys();
获取模式
获取 模式。
$schema = $tableSchema->getSchema();
获取表名
获取表名。
$tableName = $tableSchema->getTableName();
获取类型
获取列的 类型 解析器。
$name
是代表列名的字符串。
$parser = $tableSchema->getType($name);
有自增
确定表是否有自增列。
$hasAutoIncrement = $tableSchema->hasAutoIncrement();
有列
确定表是否有列。
$name
是代表列名的字符串。
$hasColumn = $tableSchema->hasColumn($name);
有外键
确定表是否有外键。
$name
是代表外键名称的字符串。
$hasForeignKey = $tableSchema->hasForeignKey($name);
有索引
确定表是否有索引。
$name
是代表索引名称的字符串。
$hasIndex = $tableSchema->hasIndex($name);
索引
获取表索引的数据。
$name
是代表索引名称的字符串。
$index = $tableSchema->index($name);
索引
获取所有表索引的数据。
$indexes = $tableSchema->indexes();
可为空
确定表列是否可为空。
$name
是代表列名的字符串。
$isNullable = $tableSchema->isNullable($name);
主键
获取表的主键。
$primaryKey = $tableSchema->primaryKey();