PHP code example of phpple / altable

1. Go to this page and download the library: Download phpple/altable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phpple / altable example snippets



ser = new Phpple\Altable\Parser();
// 设定不需要分析哪些库或者表
$parser->dbFilters = [
    // 整个库不予分析
    'mysql' => null,
    // foo.bar不予分析
    'foo' => ['bar'],
];
$dbs = $parser->parse(__DIR__.'/dump.sql');

// 开始进行分析
foreach($dbs as $db) {
    foreach($db->tables as $table) {
        foreach($table->fields as $field) {
            if ($field->name == 'uid') {
                echo "`{$db->name}`.`{$table->name}` found uid field";
            }
        }
    }
}

// 通过名称查找名称为foo的DB
$parser->find($dbs, 'foo');

// 通过名称查找名称为foo.bar的Table
$parser->find($dbs, 'foo', 'bar');

// 通过名称查找表foo.bar里的字段uid
$parser->find($dbs, 'foo', 'bar', 'uid');