Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2, print_r on collection of objects never completes
    text
    copied!<p>I am still new to Symfony2, and I am struggling my but off. I would actually like a proper answer to this question: <a href="https://stackoverflow.com/questions/19545916/symfony2-sessions-store-retrieve-array-collection-of-items-in-session">Symfony2 Sessions &gt; Store &amp; Retrieve array/collection of items in session</a> , but in the meantime I have had to resort to some "dirty" PHP using $_SESSION. However, I seem to have run into a snag where my function never completes. I am pretty sure it is because the question entity has a many to one mapping with the Quiz entity (So a quiz has questions, and each question has a quiz, which has questions, etc, etc, bad loop), but I do not know how to fix this. My code looks as follows:</p> <pre><code>public function nextQuestionAction() { $data = $this-&gt;getRequest()-&gt;request-&gt;all(); if (!isset($_SESSION['questions'])) { $quiz = $this-&gt;getDoctrine() -&gt;getRepository('CriticalReadingQuizBundle:Quiz') -&gt;find($data['quiz_id']); $questions = $quiz-&gt;getQuestions(); print_r($questions); die(); $_SESSION['questions'] = $questions; $question = $questions[0]; } else { foreach($_SESSION['questions'] as $key =&gt; $question) { if ($question['id'] == $data['question_id']) { if(isset($_SESSION['questions'][$key+1])) $question = $_SESSION['questions'][$key+1]; else { unset($_SESSION['questions']); } } } } return $this-&gt;createJsonResponse($question); } </code></pre> <p>I put in the print_r($questions); die(); to see what I get in my questions, but no surprise, that doesn't completeI either. I know that am doing/missing something stupid, but I do not know what it is. Any help will be greatly appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload