애플리케이션(PHP, 화면) 개선
This commit is contained in:
1 parent
629c8ff83f
commit
99631c1061
20 files changed
+695
-515
No files matched your search
@@ -66,23 +66,29 @@ class WritingCollection extends DBMethodContainer
|
||||
return $writingList;
|
||||
}
|
||||
|
||||
public function getWritingHighestRecord($maestroID, $playerID, $writingID)
|
||||
public function getWritingHighestRecordMap($maestroID, $playerID, $writingIDs)
|
||||
{
|
||||
$recordMap = array();
|
||||
if(count($writingIDs) === 0)
|
||||
return $recordMap;
|
||||
|
||||
// MAX + GROUP BY: UNIQUE 키가 없는 DB에서도 글당 1행. COALESCE를 쓰면 FLOAT가 DOUBLE로 바뀌어 소수점이 길어짐
|
||||
$placeholders = implode(",", array_fill(0, count($writingIDs), "?"));
|
||||
$query = "
|
||||
SELECT WritingID, HighestRecord
|
||||
SELECT WritingID, MAX(HighestRecord)
|
||||
FROM typing_exam_highest_record
|
||||
WHERE MaestroID=? AND PlayerID=? AND WritingID=?";
|
||||
WHERE MaestroID=? AND PlayerID=? AND WritingID IN (" . $placeholders . ")
|
||||
GROUP BY WritingID";
|
||||
$params = array_merge(array($maestroID, $playerID), $writingIDs);
|
||||
$stmt = $this->mysqli->prepare($query);
|
||||
$stmt->bind_param("iii", $maestroID, $playerID, $writingID);
|
||||
$stmt->bind_param(str_repeat("i", count($params)), ...$params);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($writingID, $highestRecord);
|
||||
$returnValue = $stmt->fetch();
|
||||
while($stmt->fetch())
|
||||
$recordMap[$writingID] = $highestRecord;
|
||||
$stmt->close();
|
||||
|
||||
if($returnValue === NULL || $returnValue === FALSE)
|
||||
return 0;
|
||||
|
||||
return $highestRecord;
|
||||
return $recordMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user