[Vuejs]-Array Input saves as static Word 'Array' in SQL

0👍

array_column() returns an array of values based on column name.

Does $qna1 only have one question and answer attached to it and are the values strings?

If so, you should be able to just do this, unless I’m misunderstanding the question:

$qna3_val = $qna1->question;
$qna4_val = $qna1->studentAnswer;

Otherwise as an array:

$qna3_val = $qna2['question'];
$qna4_val = $qna2['studentAnswer'];

UPDATE: I don’t remember one of your deleted comments about the details of the data structure, but for clarification this is the general idea of what I was thinking:

$testAnswers = array();
foreach ($qna1 as $questionData) {
    $testAnswers[] = array(
        'AccessId' => $token1,
        // 'Question' => implode(", ", array_values($qna2)),
        'StudentAccessId' => $token2,
        // 'TestId' => implode(" || ", array_values($qna2_val)),
        'Question' => $questionData->question,
        'StudentAnswer' => $questionData->studentAnswer
    );
}

$keys = array("AccessId", "StudentAccessId", "Question", "StudentAnswer");

$insertTest = $db->insertMulti('answertable', $testAnswers, $keys);

Leave a comment