本文整理汇总了PHP中Answer::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Answer::getAll方法的具体用法?PHP Answer::getAll怎么用?PHP Answer::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Answer
的用法示例。
在下文中一共展示了Answer::getAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findById
static function findById($search_id)
{
$found_answer = null;
$returned_answers = Answer::getAll();
foreach ($returned_answers as $answer) {
$id = $answer->getId();
if ($search_id == $id) {
$found_answer = $answer;
}
}
return $found_answer;
}
示例2: test_delete
function test_delete()
{
//Arrange
$test_field = "Joe FindById";
$test_quest_id = 1;
$test_answer = new Answer($test_field, $test_quest_id);
$test_answer->save();
$test_field2 = "Red FindById";
$test_quest_id2 = 2;
$test_answer2 = new Answer($test_field2, $test_quest_id2);
$test_answer2->save();
//Act
$test_answer->delete();
$result = Answer::getAll();
//Assert
$this->assertEquals($test_answer2, $result[0]);
}