Esempio n. 1
0
    while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
        $table = $row[0];
        $arr = explode(' ', $row[1]);
        $type = end($arr);
        if (preg_match('/#/', $table)) {
            continue;
        }
        $create = DbWrapper::getCreate($table);
        $rs = preg_match("/ENGINE=.+COMMENT='(.+)'\$/", $create, $matches);
        $comment = $rs ? $matches[1] : '';
        $table_info = compact('table', 'type', 'comment', 'create');
        $found = true;
        if ($f) {
            $found = false;
            // 这里可以用 like 语句-
            $fields = DbWrapper::getFields($table);
            foreach ($fields as $field) {
                if (preg_match('/' . $f . '/', $field['Field'])) {
                    $table_info['find_field'] = $found = true;
                    $table_info['field_matches'][] = $field;
                }
            }
        }
        if ($found) {
            $tables[] = $table_info;
        }
    }
    $tpl = 'index-list';
}
// render
include 'index.phtml';