Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/02/2012, 18:30
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
inconveniente para crear array json

hola amigos del foro

tengo inconveniente para crear array json

el primer dato no me llega id_evento

Código PHP:
Ver original
  1. <?
  2. $servidor = 'localhost';
  3. $bd = 'calendario';
  4. $usuario = 'postgres';
  5. $contrasenia = 'hoe798cs';
  6.    
  7. global $servidor, $bd, $usuario, $contrasenia;
  8. $db = new PDO('pgsql:host=' . $servidor . ';dbname=' . $bd, $usuario, $contrasenia);
  9.  
  10. $consulta = $db->prepare("SELECT * FROM eventos");
  11. $consulta->execute();
  12.  
  13. // Initializes a container array for all of the calendar events
  14. $jsonArray = array();
  15. while($fila = $consulta->fetch(PDO::FETCH_ASSOC))
  16.     {
  17.  $id =$fila['id_evento'];
  18.  $title =$fila['titulo'];
  19.  $start =$fila['inicio'];
  20.  $end =$fila['fin'];
  21.  $allDay=$fila['prueba'];
  22.  
  23.  // Stores each database record to an array
  24.  $buildjson = array('id' =>'$id_evento','title' => "$title", 'start' => "$start", 'end' => "$end", 'allDay' => "$allDay");
  25.  // Adds each array into the container array
  26.  array_push($jsonArray, $buildjson);
  27. }
  28. // Output the json formatted data so that the jQuery call can read it
  29. echo json_encode($jsonArray);
  30. ?>
}

Código SQL:
Ver original
  1. CREATE TABLE eventos
  2. (
  3.   id_evento serial NOT NULL,
  4.   titulo CHARACTER VARYING(64),
  5.   prueba BOOLEAN,
  6.   inicio TIMESTAMP WITH TIME zone,
  7.   fin TIMESTAMP WITH TIME zone,
  8.   CONSTRAINT pk_eventos PRIMARY KEY (id_evento)
  9. )