sql calc发现mysqli中的行没有返回确切的记录数(numrange)。我得到:1。它应该可以正常工作。
$sQuery1 = "SELECT SQL_CALC_FOUND_ROWS
sv_cam.image,
sv_cam.cam_id,
sv_cam.alt,
sv_orte.resort,
sv_orte.resort_us,
sv_country.sym,
DATE_FORMAT(sv_cam.lud, '%b %d') as stat
FROM sv_cam
LEFT JOIN sv_orte ON sv_cam.res_id = sv_orte.res_id AND status=0
INNER JOIN sv_canton ON sv_orte.can_id = sv_canton.can_id
INNER JOIN sv_country ON sv_canton.cou_id = sv_country.cou_id
WHERE (lud >= DATE_SUB('$today', INTERVAL 30 DAY)) ORDER BY lud desc, sv_cam.cam_id desc LIMIT $offset, $cams";
//echo $sQuery1;
$sResult1=mysqli_query($conn, $sQuery1);
$numrows = mysqli_num_rows($sResult1);
//if ($numrows<1) { exit; }
$numrange=mysqli_query($conn,"SELECT FOUND_ROWS()");
echo $numrange;
答案 0 :(得分:1)
mysql_query()
函数返回mysqli_result
个对象。因此,您需要获取结果。
$sResult2 = mysqli_query($conn, 'SELECT FOUND_ROWS() AS total');
$found_rows = mysqli_fetch_object($sResult2);
echo 'total rows'.$found_rows->total;