PHP code example of switon / sharding

1. Go to this page and download the library: Download switon/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/ */

    

switon / sharding example snippets


use Switon\Orm\Attribute\Connection;
use Switon\Orm\Attribute\Table;
use Switon\Orm\Entity;

#[Connection('db:user_id%4')]  // db_0 ... db_3
#[Table('user:user_id%8')]     // user_0 ... user_7
class User extends Entity
{
    public int $user_id;
    public string $name;
}