php代码
mallcloud商城基于SpringBoot2.x、SpringCloud和SpringCloudAlibaba并采用前后端分离vue的企业级微服务敏捷开发系统架构。并引入组件化的思想实现高内聚低耦合,项目代码简洁注释丰富上手容易,适合学习和企业中使用。真正实现了基于RBAC、jwt和oauth2的无状态统一权限认证的解决方案,面向互联网设计同时适合B端和C端用户,支持CI/CD多环境部署,并提
0
/**
* 获得分表名
* @param $tableName 基础表名
*/
function getSubTable($tableName, $companyId = null)
{
// 每张表中放50个集团的数据
$table_user = 50;
//确定 companyInfo数组
if (null === $companyId) //未指定,根据session取
{
$companyInfo = M('Company')->find(COMPANY_ID);
}
else
{
$mCompany = M('Company');
$companyInfo = $mCompany->where('id = ' . $companyId)->find();
}
//公司信息中 指定了table_name,直接取出返回
if (isset($companyInfo['table_name']) && $companyInfo['table_name'] != '')
{
return $tableName . '_' . $companyInfo['table_name'];
}
//公司信息不存在直接返回表名
if (!$companyInfo)
{
return $tableName;
}
//company表未指定id,按算法返回表名 (公司id % 50) = 分表id
$total = $companyInfo['id'] % $table_user;
//短路模式 当前面的 $total === 0 为真时候 $total = 1
$total === 0 && $total =1;
return $tableName . '_' . $total;
}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号