我正在尝试从待处理的特定卡组 (deck_id) 中获取所有抽认卡。
抽认卡待处理时
- 它没有经过测试,
next_review
未设置(新卡)或next_review <= $today
(意味着卡是由于审查)。
我目前得到的是来自不同卡片组的结果,例如deck_id 1
,deck_id 2
但我只想从同一个卡片组(如deck_id = 1
)中检索待处理的卡片。
这是我尝试过的:
//Get the untested and ready to review cards from DB
public function getCardSR($deckId)
{
$today = date('Y-m-d');
$notSet = '0000-00-00';
$query = "SELECT tbl_repetition.repetition_id,
tbl_repetition.card_id,
tbl_repetition.deck_id,
tbl_repetition.user_id,
tbl_repetition.status,
tbl_repetition.last_review,
tbl_repetition.eFactor,
tbl_repetition.inter,
tbl_repetition.repetition,
tbl_repetition.grade,
tbl_cards.front,
tbl_cards.back
FROM tbl_repetition
LEFT JOIN tbl_cards
ON tbl_repetition.card_id = tbl_cards.card_id
WHERE tbl_repetition.deck_id = :deckId AND
tbl_repetition.next_review <= :today OR
tbl_repetition.next_review = :notSet";
$stmt = $this->conn->prepare($query);
$stmt->bindParam(':deckId', $deckId);
$stmt->bindParam(':today', $today);
$stmt->bindParam(':notSet', $notSet);
$stmt->execute();
$result = $stmt->fetchAll();
return $result;
}
这是从$result
数组中检索结果的方式:
$repetition_id = $decks->getCardSR($c)[$repetitionCard] ["repetition_id"];
$eFactor = $decks->getCardSR($c)[$repetitionCard]["eFactor"];
$card_id = $decks->getCardSR($c)[$repetitionCard]["card_id"];
$deck_id = $decks->getCardSR($c)[$repetitionCard]["deck_id"];
$user_id = $decks->getCardSR($c)[$repetitionCard]["user_id"];
$status = $decks->getCardSR($c)[$repetitionCard]["status"];
$last_review = $decks->getCardSR($c)[$repetitionCard]["last_review"];
$inter = $decks->getCardSR($c)[$repetitionCard]["inter"];
$repetition = $decks->getCardSR($c)[$repetitionCard]["repetition"];
$grade = $decks->getCardSR($c)[$repetitionCard]["grade"];
$front = $decks->getCardSR($c)[$repetitionCard]["front"];
$back = $decks->getCardSR($c)[$repetitionCard]["back"];