Jump to content

Query and Array not the same order


Joak

Recommended Posts

Hello guys.

 

I execute a query and then put the records into array, the query has ORDER BY .... why I don't have the same order in the array?,  If I execute the query, the record one it's no the same that $arreglo[0].

$stmt = $this->db->prepare('SELECT a.id_torneo, b.tor_nombre, a.id_jornada, a.id_juego, a.cal_fecha_hora, id_arbitro, a.cal_estatus, a.cal_default,
         c.id_equipo, d.equ_nombre, c.enc_locvis, e.id_jugador, e.jug_nombre_pila, e.jug_apellido_pat, e.jug_apellido_mat, e.jug_representante, e.jug_numero, jug_fechimp_reg
         FROM calendario a, torneo b, encuentro c, equipo d, jugador e
         WHERE a.id_cliente =? AND a.id_sucursal = ? AND
                     date(a. cal_fecha_hora)= date(?) AND
          a.id_cliente = b.id_cliente AND
          a.id_sucursal = b.id_sucursal AND
          a.id_torneo = b.id_torneo AND
          a.id_cliente = c.id_cliente AND
          a.id_sucursal = c.id_sucursal AND
          a.id_torneo    = c.id_torneo AND
          a.id_jornada =  c.id_jornada AND
          a.id_juego =    c.id_juego AND
          a.id_cliente =   d.id_cliente AND
         c.id_sucursal =  d.id_sucursal AND
         c.id_torneo =  d.id_torneo AND
         c.id_equipo =  d.id_equipo AND
         d.id_cliente = e.id_cliente AND
         d.id_sucursal = e.id_sucursal AND
         d.id_torneo = e.id_torneo AND
         d.id_equipo = e.id_equipo AND
         e.jug_estatus = "A"
                 ORDER BY 5,11') or die(mysqli_error($this->db));
        $stmt->bind_param("iis", $cliente, $sucursal, $fecha);
        $stmt->execute();        
        $stmt->bind_result($id_torneo, $tor_nombre, $id_jornada, $id_juego, $fecha_partido, $id_arbitro, $cal_estatus, $cal_default, $id_equipo, $equipo_nombre, $locvis, $id_jugador, $jug_nombre, $jug_apellidop, $jug_apellidom, $jug_rep, $jug_playera, $jug_fechareg);        
        $arreglo = array() ;    
        $contador = 0;   
        while  ($stmt->fetch()) {
            $arreglo[$contador] = array("id_torneo"=>$id_torneo,"torneo_nombre"=>$tor_nombre,"id_jornada"=>$id_jornada,"id_juego"=>$id_juego,"fecha_partido"=>$fecha_partido,"id_arbitro"=>$id_arbitro,"cal_estatus"=>$cal_estatus,"cal_default"=>$cal_default,"id_equipo"=>$id_equipo,"equipo_nombre"=>$equipo_nombre,"locvis"=>$locvis,"id_jugador"=>$id_jugador,"jug_nombre"=>$jug_nombre,"jug_apellidop"=>$jug_apellidop,"jug_apellidom"=>$jug_apellidom,"jug_rep"=>$jug_rep,"jug_player"=>$jug_playera,"jug_fechareg"=>$jug_fechareg);
            $contador++;
        }      
Link to comment
https://forums.phpfreaks.com/topic/286498-query-and-array-not-the-same-order/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.