src/models/Schema.php
public function FKOnParams($string)
    {
        $matchs = [];
        $data = [];
        $pattern = "RESTRICT|CASCADE|NO ACTION|SET DEFAULT|SET NULL";

        // 匹配每一行
        preg_match_all("/CONSTRAINT `([0-9a-zA-Z_]+)` FOREIGN KEY .*/", $string, $matchs);

        foreach ($matchs[0] as $key => $fkSql) {
            if (strpos($fkSql, 'ON DELETE') !== false) {
                $match = [];
                preg_match("/ON DELETE ($pattern)/", $fkSql, $match);
                $data[$matchs[1][$key]]['ON DELETE'] = $match[1];
            }

            if (strpos($fkSql, 'ON UPDATE') !== false) {
                $match = [];
                preg_match("/ON UPDATE ($pattern)/", $fkSql, $match);
                $data[$matchs[1][$key]]['ON UPDATE'] = $match[1];
            }
        }

        return $data;
    }
public function FKOnParams($string)
    {
        $matchs = [];
        $data = [];
        $pattern = "RESTRICT|CASCADE|NO ACTION|SET DEFAULT|SET NULL";

        // 匹配每一行
        preg_match_all("/CONSTRAINT `([0-9a-zA-Z_]+)` FOREIGN KEY .*/", $string, $matchs);

        foreach ($matchs[0] as $key => $fkSql) {
            if (strpos($fkSql, 'ON DELETE') !== false) {
                $match = [];
                preg_match("/ON DELETE ($pattern)/", $fkSql, $match);
                $data[$matchs[1][$key]]['ON DELETE'] = $match[1];
            }

            if (strpos($fkSql, 'ON UPDATE') !== false) {
                $match = [];
                preg_match("/ON UPDATE ($pattern)/", $fkSql, $match);
                $data[$matchs[1][$key]]['ON UPDATE'] = $match[1];
            }
        }

        return $data;
    }
获取外键ON关键字参数
@param $string "show create table <table-name>"
@return array