milantex / mysql-tso
创建一个PHP对象,该对象描述了数据库中指定表的MySQL表结构。
1.0.1
2017-04-29 09:33 UTC
Requires
- php: >=7.0.0
- milantex/daw: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.4
This package is not auto-updated.
Last update: 2024-09-20 20:21:14 UTC
README
什么是MySQL-TSO?
此包提供了一种分析MySQL/MariaDB数据库中表结构的机制。最好通过查看使用示例来了解如何使用它,而不是阅读冗长的描述。
安装
使用命令行中的composer
您可以使用composer在项目的源目录中执行以下命令来安装此包
composer require milantex/mysql-tso
如果需要,请确保更新自动加载器
composer dump-autoload -o
在composer.json中将包作为依赖项
请将以下代码添加到您的composer.json中。以下是一个包含milantex/mysql-tso包要求的composer.json文件示例
{ "name": "your-name/your-project", "description": "Your project's description", "type": "project", "license": "MIT", "authors": [ { "name": "Your Name", "email": "your@mail.tld" } ], "require": { "milantex/mysql-tso": "*" } }
确保运行composer命令来安装依赖项
composer install
在项目中使用库
require_once '../vendor/autoload.php'; use Milantex\DAW\DataBase; use Milantex\TSO\TableStructureDescriptor; # Enter database parameters $daw = new DataBase('localhost', 'demo', 'root', ''); # Instantiate a table structure descriptor object $tso = new TableStructureDescriptor($daw); # Start the database analysis $tso->analyse(); if ($tso->tableExists('page') && $tso->getTableStructure('page')->fieldExists('title')) { echo 'Can page.title be null? '; if ($tso->getTableStructure('page') ->getFieldStructure('title') ->isNullable()) { echo 'Yes'; } else { echo 'No'; } }