本文整理汇总了PHP中Question::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::getAll方法的具体用法?PHP Question::getAll怎么用?PHP Question::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::getAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findById
static function findById($search_id)
{
$found_question = null;
$returned_questions = Question::getAll();
foreach ($returned_questions as $question) {
$id = $question->getId();
if ($search_id == $id) {
$found_question = $question;
}
}
return $found_question;
}
示例2: manage
public static function manage()
{
self::ensureAdmin();
// Handle creation of vanilla questions.
$createVanillaData = self::createVanilla();
// Handle deletion of questions.
self::delete();
// Handle editing of questions.
self::edit();
// Load all questions.
$questions = Question::getAll();
$typeMap = mapDataArrayByField($questions, function (Question $each) {
return $each->getVanilla();
}, [true => 'vanilla', false => 'custom']);
$viewData = ['vanilla' => [], 'custom' => []];
foreach ($typeMap['vanilla'] as $vanilla) {
$viewData['vanilla'][] = $vanilla->getData();
}
foreach ($typeMap['custom'] as $custom) {
$viewData['custom'][] = $custom->getData();
}
self::render('admin/questions', array_merge($viewData, $createVanillaData));
}
示例3: test_delete
function test_delete()
{
//Arrange
$test_field = "What is their name?";
$test_description = "What you want to call your character.";
$test_question = new Question($test_field, $test_description);
$test_question->save();
$test_field2 = "What is their profession?";
$test_description2 = "What you want your character to do.";
$test_question2 = new Question($test_field2, $test_description2);
$test_question2->save();
//Act
$test_question->delete();
$result = Question::getAll();
//Assert
$this->assertEquals($test_question2, $result[0]);
}
示例4: test_getQuestions
function test_getQuestions()
{
$name = "mikes 5 top interview questions";
$test_promptr = new Promptr($name);
$test_promptr->save();
$question = "What is your biggest weakness punk?";
$description = "This question goes straight for the jugular";
$test_question = new Question($question, $description);
$test_question->save();
$test_promptr->addQuestion($test_question);
$question2 = "Who are you really?";
$description2 = "I mean really really";
$test_question2 = new Question($question2, $description2);
$test_question2->save();
$test_promptr->addQuestion($test_question2);
$result = Question::getAll();
$end_question = new Question($question, $description, $result[0]->getId());
$end_question2 = new Question($question2, $description2, $result[1]->getId());
$this->assertEquals([$end_question, $end_question2], $result);
}