tp6 使用DB:table的一个问题,取到到了上一条查询结果的内容
$MallUser = Db::table('ea_mall_user');
if ($MallUser->where("open_id='$openId'")->count() == 1)
{
$data['msg'] = 'exist user';
echo json_encode($data);
return;
}
$maxUserId = $MallUser ->max('user_id'); //竟然取到了上一个->count()的结果总是0
if ($maxUserId < 10) {
// $maxUserId = '100000';
}
===========================================
所以需要每次都这样
$MallUser = Db::table('ea_mall_user');
if ($MallUser->where("open_id='$openId'")->count() == 1)
{
$data['msg'] = 'exist user';
echo json_encode($data);
return;
}
$maxUserId = Db::table('ea_mall_user')->max('user_id');
if ($maxUserId < 10) {
// $maxUserId = '100000';
}