定制 zortje/mysql-keeper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

zortje/mysql-keeper

最新稳定版本:0.4.0

Composer 安装命令:

composer require zortje/mysql-keeper

包简介

Find incorrect configurations or missed optimization opportunities in MySQL databases

README 文档

README

Find incorrect configurations or missed optimization opportunities in MySQL databases.

Packagist Travis branch Scrutinizer branch Scrutinizer Dependency Status Packagist

SensioLabsInsight

Features

Detects the following issues

  • Duplicate indices
  • Missing primary key on auto_increment column
  • Redundant unique index on primary key
  • Redundant key index on primary key
  • Inconsistent usage of collation between table and columns

Installing via Composer

The recommended way to install MySQL Keeper is though Composer.

{
    "require": {
        "zortje/mysql-keeper": "~0.0"
    }
}

Usage

$pdo = new PDO('mysql:host=127.0.0.1;dbname=myapp', 'root', '');

$database = DatabaseFactory::create($pdo);
$databaseResult = $database->getResult();

The $databaseResult array will look something like this with the first level keys being table names.

[
	'users' => [
		'issues' => [
			[
				'type' => 'field',
				'field' => 'id',
				'description' => 'Set as auto_increment but has no primary key'
			],
			[
				'type' => 'field',
				'field' => 'id',
				'description' => 'Set as auto_increment but is not set as primary'
			]
		],
		'optimizations' => [
			[
				'type' => 'field',
				'field' => 'id',
				'description' => 'Field should be unsigned, as no field values are negative'
			]
		]
	]
];

Usage with Melody

Melody allows inline Composer requirements to simply execute PHP scripts.

mysql-keeper_myapp.php

<?php

<<<CONFIG
packages:
    - "zortje/mysql-keeper": "~0.0"
CONFIG;

$pdo = new PDO('mysql:host=127.0.0.1;dbname=myapp', 'root', '');

$database = Zortje\MySQLKeeper\DatabaseFactory::create($pdo);

print_r($database->getResult());

Simply run:

$ melody run mysql-keeper_myapp.php

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-17