PHP code example of rice / lavavel-sharding
1. Go to this page and download the library: Download rice/lavavel-sharding library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rice / lavavel-sharding example snippets
namespace App\Models;
use Rice\LSharding\DatetimeSharding;
class Users extends DatetimeSharding
{
protected $table = 'users';
// 开始值 (根据最开始出现的时间确认第一张分表)
public function lower()
{
return '2024-09-01 00:00:00';
}
// 结束值 (null默认就是当前时间)
public function upper()
{
return null;
}
// 分表后缀(Carbon的format)
public function suffixPattern()
{
return 'ym';
}
}