PHP Classes

File: MySqlInfoExample.php

Recommend this page to a friend!
  Classes of Stefan Kientzler   PHP MySQL Info to MD   MySqlInfoExample.php   Download  
File: MySqlInfoExample.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP MySQL Info to MD
Generate a MySQL table structure Markdown report
Author: By
Last change:
Date: 1 year ago
Size: 1,592 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);

use
SKien\MySqlTools\MySqlInfoMD;

/**
 * Generating report for MySQL Database in MD format.
 *
 * @author Stefanius <s.kientzler@online.de>
 * @copyright MIT License - see the LICENSE file for details
 */
include_once "autoloader.php";

$strDBHost = 'localhost';
$strDBName = 'demo';
$strDBUser = 'demo';
$strDBPwd = 'demoPWD';
$oDB = mysqli_connect($strDBHost, $strDBUser, $strDBPwd, $strDBName);

$iType = intval($_GET['type'] ?? '0');
$oInfo = new MySqlInfoMD($oDB, $iType);
switch (
$iType) {
    case
MySqlInfoMD::STANDALONE:
       
$oInfo->setOptions(MySqlInfoMD::OPT_CREATE_SUBFOLDER | MySqlInfoMD::OPT_CREATE_STMT);
       
$oInfo->setPath('/Example');
       
$oInfo->setImagePath('/images');
        echo
'Database information generated (Type: STANDALONE)';
        break;
    case
MySqlInfoMD::GITHUB_WIKI:
       
$oInfo->setOptions(MySqlInfoMD::OPT_CREATE_TOC | MySqlInfoMD::OPT_CREATE_STMT);
       
$oInfo->setPath('/GitHubWiki');
       
$oInfo->setImagePath('/images');
        echo
'Database information generated (Type: GITHUB_WIKI)';
        break;
    case
MySqlInfoMD::SKIEN_WIKI:
       
$oInfo->setOptions(MySqlInfoMD::OPT_CREATE_SUBFOLDER | MySqlInfoMD::OPT_CREATE_STMT | MySqlInfoMD::OPT_NO_INDEXLINK);
       
$oInfo->setRoot($_SERVER['DOCUMENT_ROOT']);
       
$oInfo->setPath('/packages/MySqlInfoMD/wiki/DBDesign');
       
$oInfo->setImagePath('/packages/MySqlInfoMD/wiki/images');
        echo
'Database information generated (Type: SKIEN_WIKI)';
        break;
}
$oInfo->buildInfo();