簡體   English   中英

如何在PDO中正確計算查詢

[英]How to properly count a query in pdo

我正在嘗試將更多帖子動態加載到我的系統中

這是我的代碼...

$stmt = "
  SELECT * FROM `acmPosting` 
  WHERE (`sender`='$thisID' AND `postType`='a')
  OR (`recip`='$thisID' AND `sender`='$userID' AND `postType`='a')
  OR (`sender` IN ($friendsArray) AND `recip`='$thisID'  AND `postType`='a')
  ORDER BY `timeSent` DESC LIMIT $startlimit,10";

    if($stmtCount = $conn->query($stmt)){
        if($stmtCount->fetchColumn() > 0){
            $result = acmPosts($conn, $site, $userID, $stmt);
            $jsonArray['a'] = $result;
            $jsonArray['b'] = 'go';             
        }else{
            $jsonArray['a'] = '<div class="thisOutput" style="padding:12px;">There are no more posts</div>';
            $jsonArray['b'] = 'stop';
        }
    }

直到它到達最后一組職位的AKA如果限制100,10但也有105個職位的通話也不會調用任何的fetchColumn(),一切工作正常。

我希望這個問題有意義。 在此先感謝您提供的任何幫助。

編輯

如何確定何時達到極限並采取相應措施

您的描述不是很准確,但是也許這是您想要的:

http://dev.mysql.com/doc/refman/5.0/zh-CN/information-functions.html#function_found-rows

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM