MYSQL:
SQL_CALC_FOUND_ROWS
After viewing the manual, we found that this keyword is used to count the total number of results that meet the filtering conditions during the query (not limited by Limit). For example:
[sql] SELECT SQL_CALC_FOUND_ROWS tid FROM cdb_threads WHERE fid=14 LIMIT 1,10;
Suppose there are 1000 conditions, and 10 are returned here. Use now
[sql] SELECT found_rows() AS rowcount;
The returned rowcount is 1000. This saves a considerable amount of time for repeated queries of SELECT count (*) AS rowcount. The following are the applications that should be applied in the game flavor:
[SQL] function mail_list_sent ($ uid, $ start) {// note that no comma $ query = "SELECT SQL _CALC_FOUND_ROWS uid, real_name, current_city, msg_uid, sender_flag ,". "msg_title, msg_content FROM ". TT_DBTABLEPRE. "mailbox as mb1 ,". TT_DBTABLEPRE. "user as usr1 WHERE mb1.sender _ id = usr1.uid AND mb1.sender _ id = $ uid AND sender_flag> 0 LIMIT $ start ,". TT_PAGESIZE; $ mails = $ this-> db-> fetch_all ($ query); // query the number of rows that meet the conditions in the SELECT statement, unrelated to the LIMIT clause $ max_count = $ this-> db-> fetch_first ("SELECT found_rows () AS rowcount"); $ tmp ['State _ Code'] = 200; $ tmp ['info'] = "OK"; $ tmp ['LIST'] = $ mails; $ data = json_encode ($ tmp); return $ data ;}