haozhen
    //哈希分表
    function get_hash_table($table, $userid) {
        $str = crc32($userid);
        if ($str < 0) {
            $hash = "0" . substr(abs($str), 0, 1);
        } else {
            $hash = substr($str, 0, 2);
        }
        return $table . "_" . $hash;
    }
    public function index() {

        echo $this->get_hash_table(\'message\', \'18991\').\'<br>\';
        echo $this->get_hash_table(\'message\', \'18993\').\'<br>\';
        echo $this->get_hash_table(\'message\', \'18994\').\'<br>\';
        
    }

 

分类:

技术点:

相关文章: