<?php
namespace App\Controllers;
SESSION_START();
use \Core\View;
use \Core\Inputs;
use \Core\Userlog;
use \Core\Menu;
use \Core\Form;
use App\Models\Homem;
use App\Email\Emails;
class Schema extends \Core\Controller
{
    private static function dbnames()
    {
        $data = '{
            "1": "hinduengg_hindu_main_unaided",
            "3": "hinduengg_hindu_engg",
            "4": "hinduengg_hindu_mca",
            "5": "hinduengg_hindu_management"
        }';
        return json_decode($data, true);
    }
    public static function tables()
    {
        $data = static::dbnames();
        for($i=1; $i<=5; $i++)
        {
            if($i != 2)
            {
                $_SESSION['org_id'] = $i;
                $dbname = $data[$i];
                $tdata[$i] = Homem::getdata("SELECT table_name FROM information_schema.tables WHERE table_schema = '$dbname'");
                $tsize['dbid'][$i] = $_SESSION['org_id'];
                $tsize['dbsize'][$i] = sizeof($tdata[$i]);
            }
        }
        echo json_encode($tsize);
        // $data = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'hinduengg_hindu_engg'";
    }
    public static function createtable()
    {
        $query = "DESCRIBE hinduengg_hindu_management.user_master";
        $_SESSION['org_id'] = 5;
        $dbname='hinduengg_hindu_management';
        $table = 'user_master';
        $query = "show create table $dbname.$table";
        $data = Homem::getdata($query);
        echo $data[0]["Create Table"];
        // echo json_encode($data);
    }
}