I'm trying to convert a php array into a json-friendly format but the
following code doesn't output anything:

### Controller:

<?php
class ChannelsController extends AppController {

        var $name = 'Channels';

        function results($page=0,$limit=5) {
                $this->layout = "ajax";  //make cake use the ajax layout
                $channelArray = array();  //this will hold our data from the
database.
                $count = $this->Channel->findCount(); //counts the number of 
records
in Message.
                $channelA = $this->Channel->find('all', array('limit'=>
$limit,'page'=>$page,'order' => 'Channel.name DESC')); //gets all the
Channel records and sorts them by name.
                $channelArray = Set::extract($channelA, '{n}.Channel');  
//convert
$productArray into a json-friendly format
                $this->set('total', $count);  //send total to the view
                $this->set('page_size', $limit);
                $this->set('channel_list', $channelArray);  //send messages to 
the
view
        }

}
?>


### View:

<?php
        echo '{"totalRecords":' . $total . ', "recordsReturned":' .
$page_size . ', "records":' . $javascript->Object($channel_list) .
'}';
?>


I've debugged the source and it seems that the $javascript->Object()
is not doing its job and is not outputting anything. Is there any
configuration to dd or am I wrong writing anything ?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to