Symfony - Query Result Convert to Json

904 views Asked by At

I have been searching the web about this problem and have not been very lucky.

I am using symfony to retrieve data from the database to load in to a extjs library. My problem is when loading the data, an error occurs saying "Ext.Error: You're trying to decode an invalid JSON String"

I queried the database correctly because it returns a set of data. The problem I think is with converting the array to json format.

Here is what it display when debugging my returned json format:

returned json format

and my code to that is:

  public function executeGetData(sfWebRequest $request)
  {
      $SQL = " SELECT sked.id, sked.program_id, sked.agentname,
            sked.customername, sked.customercontact, sked.callback_dt,
            sked.callback_dt AS date_closed
            FROM schedule sked LIMIT 5";

$Doctrine_Manager = Doctrine_Manager::getInstance()->getConnection('callback_tracker');
$result = $Doctrine_Manager->fetchAll($SQL);

$final = array("evts" => $result);

$finalJson = json_encode($final);
echo $finalJson;

My Event Store:

   var eventStores = Ext.create('Extensible.calendar.data.EventStore', {
//autoLoad: true,
id: 'calStore',
proxy: {
    type: 'rest',
    url: '/home/GetData',
    //appendId: false,
    method: 'POST',
    reader: {
    type: 'json',
    root: 'evts'
    },

    writer: {
    type: 'json',
    nameProperty: 'mapping'
    },

    listeners: {
    exception: function(proxy, response, operation, options){
        var msg = response.message ? response.message : Ext.decode(response.responseText).message;
        // ideally an app would provide a less intrusive message display
        Ext.Msg.alert('Server Error', msg);
    }
    }
},

listeners: {
    'write': function(store, operation){
    var title = Ext.value(operation.records[0].data[Extensible.calendar.data.EventMappings.Title.name], '(No title)');

    console.debug('Operation Action = ' + operation.action);
    switch(operation.action){
        case 'create': 
        //Extensible.example.msg('Add', 'Added "' + title + '"');
        break;
        case 'update':
        //Extensible.example.msg('Update', 'Updated "' + title + '"');
        break;
        case 'destroy':
           //Extensible.example.msg('Delete', 'Deleted "' + title + '"');
        break;
    }
    }
}
});

I load it afterRender of the Calendar.BTW, the library I am using is Extensible Calendar.

What is the problem here? Is it the json format? how do you convert this?

0

There are 0 answers