mysql 两个不关联的表 列表分页
文章目录mysql 两个不关联的表 列表分页代码框架 tp5代码示例mysql 两个不关联的表 列表分页代码框架 tp5代码示例if ($type == 1) {$sql = "SELECT uid,money,get_time,expire_time,change_time,status,invited_uid,remark,maxMoney,1 AS type,change_id,0 AS w
·
mysql 两个不关联的表 列表分页
代码框架 tp5
代码示例
if ($type == 1) {
$sql = "SELECT uid,money,get_time,expire_time,change_time,status,invited_uid,remark,maxMoney,1 AS type,change_id,0 AS withdraw_id FROM pubm_coin_changeup_ticket " . $where;
$countSql = "SELECT count(*) AS total FROM pubm_coin_changeup_ticket " . $where;
} elseif ($type == 2) {
$sql = "SELECT uid,money,get_time,expire_time,change_time,status,0 AS invited_uid,remark,maxMoney,2 AS type,0 AS change_id,withdraw_id FROM pubm_cash_drawup_ticket " . $where;
$countSql = "SELECT count(*) AS total FROM pubm_cash_drawup_ticket " . $where;
} else {
$sql = "SELECT uid,money,get_time,expire_time,change_time,status,0 AS invited_uid,remark,maxMoney,2 AS type,0 AS change_id,withdraw_id FROM pubm_cash_drawup_ticket " .
$where . " UNION ALL SELECT uid,money,get_time,expire_time,change_time,status,invited_uid,remark,maxMoney,1 AS type,change_id,0 AS withdraw_id FROM pubm_coin_changeup_ticket " .
$where;
$countSql = "SELECT SUM(a.b) AS total FROM ( SELECT COUNT(*) AS b FROM pubm_coin_changeup_ticket " . $where .
" UNION SELECT COUNT(*) AS b FROM pubm_cash_drawup_ticket " . $where . ") AS a";
}
$sql .= ' order by get_time desc';
if ($limit > 0) {
$sql .= ' limit ' . $offset . ',' . $limit;
}
$data = Db::query($sql);
if ($count == 0 && $limit > 0) {
$countData = Db::query($countSql);
$count = $countData[0]['total'];
}
更多推荐
已为社区贡献2条内容
所有评论(0)