<?php

namespace App\Services\TG\Hook\Mod;
//use App\Models\Article as ModelArticle;

class Db extends Base {
    
    public function sql($aParam)
    {
        if ($aParam["aArg"][1] == "?") {
            return "/db#sql {value}";
        }
        
        $aValue = $aParam["aArg"];
        $sValue = implode(" ", $aValue);
        
        $r = \DB::statement($sValue);
        
        return $r;
    }
    
    public function me()
    {
        $str = "
    添加字段：ALTER TABLE `ship` ADD `good_test` TEXT DEFAULT NULL AFTER `api_huodong`

    删除字段：ALTER TABLE `ship` DROP COLUMN `good_test`

    修改字段：ALTER TABLE `ship` MODIFY `good_test` VARCHAR(255) DEFAULT NULL
";
        
        return $str;
    }
    
    public function showCreateTable($aParam)
    {
        $sValue = $aParam["aArg"][1] ?? false;
        
        $columns = \DB::select("SHOW CREATE TABLE `{$sValue}`");
        
        return $columns[0]->{"Create Table"};
    }
    
}
