не удается вставить массовую запись с помощью php codeigniter - PullRequest
0 голосов
/ 10 декабря 2018

С этим массивом я пытаюсь вставить его в таблицу, используя insert_batch .

$arrayOfQuestions содержит несколько массивов, как показано ниже:

Array
(
    [0] => Array
        (
            [question_desc] => In human beings, partial pressure of carbon dioxide in the inspired and expired air is respectively
            [option_a] => 0.3 and 40 mm Hg
            [option_b] => 0.3 and 32 mm Hg
            [option_c] => 40 and 46 mm Hg
            [option_d] => 40 and 0.3 mm Hg
            [answer] => B
            [diff_level] => 4
            [solution] => Refer answer.
            [chapter_id] => 54
            [inst_id] => 1
            [subject_id] => 68
            [ref_q_id] => 8540371983
        )

    [1] => Array
        (
            [question_desc] => At high altitude, RBCs of human blood will
            [option_a] => Increase in number
            [option_b] => Decrease in number
            [option_c] => Decrease in size
            [option_d] => Increase in size
            [answer] => A
            [diff_level] => 2
            [solution] => At higher altitudes, due to low pressure of atmospheric oxygen, the body has to carry more oxygen than normal in per volume of blood to supply the body constantly. The increased number of RBC in blood ensures the presence of more haemoglobin and thus more oxygen is carried.
            [chapter_id] => 54
            [inst_id] => 1
            [subject_id] => 68
            [ref_q_id] => 8540371983
        )
)

Я получаю возвращаем true с кодом, который я пробовал ниже, но данные не вставленык столу ..

$result = $this->db->insert_batch('test_temp_question', $arrayOfQuestions);

1 Ответ

0 голосов
/ 10 декабря 2018

для успешной вставки данных используйте условие для него:

if($result>0){
echo"successfull.";
}
else{
echo"not successfull";
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...