xiaolin / laravel-table
laravel table shard compents
0.0.5
2018-06-28 07:44 UTC
Requires
- php: >=7.0
- phalcon/dd: ^1.1
Requires (Dev)
- laravel/framework: 5.5.*
- phpunit/phpunit: >=5.6
Suggests
- ext-pcntl: Required to use all features of the queue worker.
- ext-posix: Required to use all features of the queue worker.
- aws/aws-sdk-php: Required to use the SQS queue driver and SES mail driver (~3.0).
- doctrine/dbal: Required to rename columns and drop SQLite columns (~2.6).
- fzaninotto/faker: Required to use the eloquent factory builder (~1.4).
- guzzlehttp/guzzle: Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (~6.0).
- laravel/tinker: Required to use the tinker console command (~1.0).
- league/flysystem-aws-s3-v3: Required to use the Flysystem S3 driver (~1.0).
- league/flysystem-cached-adapter: Required to use the Flysystem cache (~1.0).
- league/flysystem-rackspace: Required to use the Flysystem Rackspace driver (~1.0).
- league/flysystem-sftp: Required to use the Flysystem SFTP driver (~1.0).
- nexmo/client: Required to use the Nexmo transport (~1.0).
- pda/pheanstalk: Required to use the beanstalk queue driver (~3.0).
- predis/predis: Required to use the redis cache and queue drivers (~1.0).
- pusher/pusher-php-server: Required to use the Pusher broadcast driver (~3.0).
- symfony/css-selector: Required to use some of the crawler integration testing tools (~4.0).
- symfony/dom-crawler: Required to use most of the crawler integration testing tools (~4.0).
- symfony/psr-http-message-bridge: Required to psr7 bridging features (~1.0).
- tamayo/laravel-scout-elastic: An Elasticsearch Client
This package is not auto-updated.
Last update: 2025-03-11 06:45:54 UTC
README
Laravel Table Sharding
安装
composer xialin/table
注入
'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Notifications\NotificationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, /* * Package Service Providers... */ /* * Application Service Providers... */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, \OkamiChen\TableShard\TableShardProvider::class, // 分表 ],
创建
use Illuminate\Database\Eloquent\Model; use OkamiChen\TableShard\Traits\TableShard; class User extends Model { use TableShard; /** * 分表建值 * @return string */ public function getShardKey() { return 'user_id'; } /** * 分表个数 * @return int */ public function getShardNum() { return 10; } }
查询
User::where(['user_id'=>18])->first();