0
votes

I have a Symfony 1.4 and Doctrine 1.2 project running and have a problem with output escaping in one of my DB calls.

The thing is, I am not retrieving a PHP object in my Doctrine query, but rather an array in PHP. The reason why I am doing this is another topic altogether, let's just say getting a PHP object would not be the solution. Essentially the query is an inner join between two doctrine models. Model 1 inner joins with Model 2 and the results yielded can be accessed like this:

foreach($results as $result)
{
 echo $result['field1']; // accessing results for model 1 
 echo $result['model2']['field1']; // accessing results for model 2 (this inner joins with the model)
}

Now for the above, more specifically for model2, field1 consists of HTML markup, which is naturally output escaped. I need the HTML markup to be rendered as it is! Which is where the problem lies,

if this was a regulation Doctrine object, a simple $modelObject->getRawValue()->getField(); would render HTML markup without escaping it. I am not sure how HTML markup can be rendered in a PHP array?

Thanks

1
I wonder, if you print_r($result) inside your loop, you might find it is wrapped in an escaper object. If so, you should be able to use getRawValue() on its elements as well? - halfer
Halfer, most of your solutions are comments, how do I accept those as answers ? - user1020069
If you see a comment that works for you, just ask the poster to copy their comment into an answer, and accept! I do it all the time. If that helped, then great - been there, scratched my head for ages :-). - halfer
Halfer post the comment as an answer, you got it! - user1020069

1 Answers

2
votes

(Copied from my earlier comment). I wonder, if you print_r($result) inside your loop, you might find it is wrapped in an escaper object. If so, you should be able to use getRawValue() on its elements as well?

This works because the escaper object implements the Iterator interface (so you can do the foreach over it) and also ArrayAccess (so it appears to work like an array).