Considering donating if you found my post helpful 😊
Semasa memanggil fetch() untuk mendapatkan hasil dari pertanyaan (query) SQL.
Kod yang saya punyai adalah
if($sqlexec = $db->query("SELECT * from torrent WHERE running IN(0)")){
print("Looping through ".$sqlexec->num_rows." records.\n\n");
$i=0;
while($row = $sqlexec->fetch_assoc()){
$i++;
print("Processing record ".$i."\n.");
$rpc->GetSessionID();
$hash = $row['hash'];
$id = $row['owner'];
$added = $row['time_added'];
$done = $row['time_done'];
$get = $rpc->get($hash, array( 'id', 'name', 'eta', 'etaIdle', 'downloadDir', 'peersSendingToUs', 'percentDone', 'rateDownload', 'totalSize', 'hashString', 'isFinished', 'isStalled', 'activityDate', 'doneDate'));
$sizeGB = ceil($get->arguments->torrents[0]->totalSize /1000/1000/1000);
$expireIn = $sizeGB*$expiry;
if($sqlexec = $db->query("SELECT * from torrent WHERE running IN(0) AND hash='".$hash."'")){
if($sqlexec->num_rows<=1){
if(($done + ($expireIn*60*60)) <= time()){
$del = $rpc->remove(array($hash), true);
}
}
}
}
Gelung (loop) while ini berjalan tanpa henti. Setelah diteliti, saya menggunakan pemboleh ubah yang sama pada kedua-dua pertanyaan (query) 1 dan 18.
Setelah menggunakan pemboleh ubah yang berbeza, akhirnya kod ini berjalan dengan sempurna.
Considering donating if you found my post helpful 😊