digitaldream/dbreader 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

digitaldream/dbreader

最新稳定版本:1.4

Composer 安装命令:

composer require digitaldream/dbreader

包简介

Database Reader

README 文档

README

For some kind of automation tools we need to know database constraints like tables, fields and its indexes. But its very hard and painful to get this information from directly database. This tool will make this task super simple.

Installation

Add this line on your composer.json

    "require":{
        "digitaldream/dbreader":"~1.0"
    }

Settings

Set Database information on top of page.

\DbReader\Database::settings([
    'database' => "YOUR_DATABASE_NAME",
    'username' => "YOUR_DATABASE_USERNAME",
    'password' => "YOUR_DATABSE_PASSWORD",
    // or you can just assign a pdo object via
    // 'pdo'=> $your_pdo_object
    //Below are optional columns
    'manualRelations' => [
        'tours.start_location' => 'locations.id',
        'tours.end_location' => 'locations.id'
    ],
    'ignore' => [],
    'protectedColumns' => ['id', 'created_at', 'updated_at'],
    'files' => ['users.avatar']
]);

Database

$db=new \DbReader\Database();
print_r($db->tables()); // return array of tables
// You can also access a individual table object
print_r($db->users); // It will return \DbReader\Table Object
// Even further
print_r($db->users->id) // It will return \DbReader\Column Object

Table

$user=new \DbReader\Table('users');
print_r($user->columns()) // return all columns as array of StdClass
print_r($user->columnClasses()) // return list of Column Class object as array. Most preferable rather than columns()
print_r($user->relations()); // return all the Foreign Relation of a given table. 
print_r($user->indexes()); // return all the Indexes of given table. 

Column

$user=new \DbReader\Table('users');
echo $user->email->name(); // name of the column
echo $user->email->type(); // type Column data type enum, int, text etc
echo $user->email->length(); //  return length e.g. 255 for varchar
echo $user->email->defaultValue(); 
echo $user->email->isPk();
echo $user->email->isUnique();
echo $user->email->isNull();
echo $user->email->isForeign();

N.B: This is a submodule of LaraCrud and only Support Mysql Database now.

统计信息

  • 总下载量: 20.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-12