在 Laravel 5.4 中获取 table 校验和

Get table checksum in Laravel 5.4

你用什么来得到Laravel中table的校验和?是否已经为此抽象了一些东西,或者您必须使用原始命令?

您必须使用原始命令,但这很简单,只需将此方法添加到您的模型中即可:

public static function checksum()
{
    $tableName = with(new static)->getTable();
    $query = sprintf('CHECKSUM TABLE %s', $tableName);

    return \DB::select(\DB::raw($query))[0]->Checksum;
}

您现在可以静态调用此方法来获取校验和。