/** * Save a question array in the database * Often used in a foreach loop to loop over all questions * If ID is passed, it will update that ID. * If no ID or ID = 0, it will insert * * @param $question = array(); of question data * @return ID of saved question or false if error * @since 0.0.1 */ protected function save_question($question) { // set the question array self::$question = $question; // check to see if the id exists if (self::$question['question_id'] === 0) { // It doesn't exist yet, so insert it! $this->insert_question(); } else { // we have a question_id, so update it! $this->update_question(); } }
/** * Loop through a $quiz['question'] array to save to the db * * @param $question = array(); of all $quiz['question'] data * @since 0.0.1 */ protected function save_questions() { // loop through the questions and save each one foreach (self::$quiz['question'] as $question) { // save it! Yay! // get access to the question object $question_obj = new Enp_quiz_Save_question(); // save the question $question_obj->save_question($question); } }