Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/09/2013, 21:15
rodojpm
 
Fecha de Ingreso: julio-2010
Mensajes: 127
Antigüedad: 13 años, 9 meses
Puntos: 2
Problema con 'UPDATE' y affected_rows = -1

Estoy creando una función en mysql que se supone debe actualizar unas filas en la base de datos, cuando envío la consulta esta me devuelve 'affected_rows = -1' pero ningún error.

Imprimí la consulta y la usé en phpmyadmin y funcionó perfectamente.

Código PHP:
function updateGallery($matrix)
{
    global 
$mysqli;
    
$query "";
    
$i=0;
    
$count count ($matrix);
    while(
$i<$count)
    {
        
$matrix[$i][0] = $mysqli->real_escape_string($matrix[$i][0]);
        
$matrix[$i][1] = $mysqli->real_escape_string($matrix[$i][1]);
        
$matrix[$i][2] = $mysqli->real_escape_string($matrix[$i][2]);
        
$query .= "UPDATE gallery SET category = '".$matrix[$i][1]."', position = ".$matrix[$i][2]."  WHERE id = ".$matrix[$i][0]. "; ";
        
$i++;
    }
    
$result $mysqli->query($query);
    return 
$mysqli->affected_rows;


Este es un ejemplo de la consulta que me genera:
Cita:
UPDATE gallery SET category = 'Not published', position = 0 WHERE id = 39; UPDATE gallery SET category = 'Not published', position = 1 WHERE id = 41; UPDATE gallery SET category = 'Not published', position = 2 WHERE id = 40; UPDATE gallery SET category = 'Not published', position = 3 WHERE id = 38; UPDATE gallery SET category = 'Not published', position = 4 WHERE id = 36;
__________________
Mi ultima web.