/** |
* @param string $table_name 表名 |
* @param int $user_id 用户id |
* @param int $total 分表总数 |
* @link http://www.phpddt.com |
*/ |
function hash_table( $table_name , $user_id , $total ) |
{ |
return $table_name . '_' . (( $user_id % $total ) + 1); |
} |
echo hash_table( "artice" , 1234, 5); //artice_5 |
echo hash_table( "artice" , 3243, 5); //artice_4 |