Tuesday, April 2, 2013

Cake 1.3 - Set::insert + $this->set() issue

In a controller I have the following:

        $cities = $this->City->find('all');
        foreach($cities as $x => $c){
            $cities[] = Set::insert($cities[$x], 'ads', array('count' => $this->get_ad_count($c['City']['slug'])));
        }
       //print_r($cities);
       //exit;
        $this->set('cities',$cities);

  • When running the code as shown above, with Debug set to '2', the view returns absolutely nothing. Just a white screen.
  • if I run print_r() I will see a well formatted array with the 'ads' key/value pair inserted correctly.
  • If I remove the foreach lines I see a perfectly nice view with the correct data (obviously without the 'ads' stuff) displayed.

Might Set::insert be interfering with $this->set in some way?

Perhaps there is some security involved with $this->set that doesn't allow the insertion?

Not sure what gives. Anybody have a clue?

Thanks,

Javier


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: