Partage
  • Partager sur Facebook
  • Partager sur Twitter

Récupération d'un Json

    15 décembre 2010 à 16:04:28

    Bonjour à tous,
    j'ai un problème pour récupérer la valeur d'un Json.

    // Execution de la requête
    $sth = $dbh->query($req);
    $result = $sth->fetchAll(PDO::FETCH_ASSOC);
     
    if($result)
    {
    	// On récupère la liste des tickets
    	foreach($result as $data)
    	{
    		$ticket = array('noAppel'		=>	htmlentities($data['noAppel']),
    						'dateAppel' 	=>	$data['dateAppel'],
    						'dateCloture' 	=>	$data['dateCloture'],
    						'statut' 		=>	htmlentities($data['statut']),
    						'technologie' 	=>	htmlentities($data['technologie']),
    						'POP'			=>	htmlentities($data['POP']),
    						'dept'			=>	htmlentities($data['dept']),
    						'Criticite'		=> 	htmlentities($data['Criticite']),
    						'Symptome'		=>  htmlentities($data['Symptome']),
    						'signalisation' =>  htmlentities($data['signalisation']),
    						'x'				=> 	htmlentities($data['latitude']),
    						'y'				=> 	htmlentities($data['longitude']));
    		
    		$ret['ticket'][] = $ticket;
    		$ret['total'] = $data['Total'];
    	}
    }
     
    // Deconnexion de la base de donnees
    $dbh = null;
     
    echo json_encode($ret);
    


    J'utilise ces infos habituellement dans un grid via extjs.


    // Store des tickets en cours
    	var stoTicketsClos = new Ext.data.Store({
    		storeId: 'stoTicketsClos',
    		url: 'data/incidents/getTicketsBackbone.php',
    		remoteSort: true,
    		autoLoad: true,
    		method: 'POST',
    		baseParams: {
    		
    		
    			rechDate:		'',
    			rechNumero:		'',
    			rechCriticite:	'',
    			rechPop:		'',
    			rechStatut:		'',
    			statut: 'C',
    			depts: 	listeDepts,
    			sort:	'',
    			dir:	'ASC',
    			start:	0,
    			limit:	20,
    			total:	0
    		},
    		reader: 
    			new Ext.data.JsonReader({
    				totalProperty: 'total',
    				root: 'ticket'
    			},
    			new Ext.data.Record.create([
    				{name: 'noAppel',		type: 'int'}, 
    				{name: 'dateAppel',		type: 'date'}, 
    				{name: 'dateCloture',	type: 'date'}, 
    				{name: 'statut',		type: 'string'},
    				{name: 'technologie',	type: 'string'},
    				{name: 'POP',			type: 'string'},
    				{name: 'dept', 			type: 'string'},
    				{name: 'Criticite',		type: 'string'},
    				{name: 'signalisation',	type: 'string'},
    				{name: 'Symptome',		type: 'string'}, 
    				{name: 'x',				type: 'decimal'},
    				{name: 'y',				type: 'decimal'}
    			])
    		)
    	});
    


    Mais je souhaiterais récupéré mon Json tout bêtement dans un autre fichier en appelant mon Json sans passer par extjs.

    J'espère avoir été clair pour mon souci.
    • Partager sur Facebook
    • Partager sur Twitter

    Récupération d'un Json

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown