コード例 #1
0
function question_model_test($delete)
{
    include_once "page_model.php";
    $qa_pairs = array("question" => "where would you like to go?", "answers" => array("1" => "left", "2" => "right", "3" => "south"));
    $question = new QuestionModel(PageModel::first()->id, serialize($qa_pairs), date("Y-m-d H:i:s"));
    $question->save();
    $question->print_fields();
    $qa_pairs = array("question" => "Will you open the door?", "answers" => array("1" => "yes", "2" => "no"));
    $question->set("q_and_a", serialize($qa_pairs));
    $question->save();
    $question->print_fields();
    if ($delete) {
        $question->delete();
    }
    $qm = QuestionModel::find(QuestionModel::last()->id);
    $qm->print_fields();
    QuestionModel::find(999);
}