だから私はこのプログラムをコーディングしています。これは基本的にアスタリスクのバックエンドシステムであり、すべての通話、通話時間、通話日、ユーザー名などを管理者に表示します。以前は、データベース内のすべてのユーザーをループする for ループがありました。その中にはいくつかの関数があり、各関数は常にこのステートメントを呼び出すために使用されていました。
$stmt="select callcharge,billsec,src,dst,calldate from cdr where (src='$ext[$x]' or src='238800$ext[$x]') and calldate>='$startdate' and calldate<='$stopdate' and length(dst)>3 and (dst like '7%' or dst like '9%') and billsec>5";
$result=mysql_query ($stmt);
すべてのユーザーに対してこれを行います (それぞれ独自の拡張子を持つ) {VERY VERY SLOWW!}
代わりに、このステートメントを for ループの外で 1 回呼び出すことで、読み込み時間を短縮しようとしています。
$stmtf="select callcharge,billsec,src,dst,calldate from cdr where calldate>='$startdate' and calldate<='$stopdate' and length(dst)>3 and dst like '2%' and billsec>5";
$results=mysql_query ($stmtf);
内線番号によるフィルタリングが行われていないことに注意してください (内線番号ごとにすべての情報を呼び出します)。
今私がやりたいことはこれです: この mysql クエリを一度だけ呼び出した後、すべてのデータが変数 $stmtf に格納された後、for ループに入り、このクエリでその $stmtf 変数を何らかの形でフィルタリングできるようにしたい(src='$ext[$x]' or src='238800$ext[$x]')
ここでの私の目標は、必要なデータは同じで、内線番号が異なるだけなので、for ループからデータベースに大量の要求を行うのではなく、データベースに一度要求を行うことです。