I am trying the following query and it just doesn't store any values into the table.
Column Tienda is set to unique. The pk is Codigo and the query is:
$asignaciones = $db->query("
INSERT INTO `Asignaciones` (
`Codigo` , `Tienda` , `Apertura` , `Cierre_20_00` , `Cierre_20_30` , `Cierre_21_00` , `Sanitarios` , `Barrer_Mat` , `Barrer_Vesp` , `Trapear_Mat` , `Trapear_Vesp` , `Limpiar_Ventanales_y_Vitrinas` , `Fecha` , `Encargada` , `Supervisora` )
VALUES (NULL , '$Tienda', '$Apertura', '$Cierre_20_00', '$Cierre_20_30', '$Cierre_21_00', '$Sanitarios', '$Barrer_Mat', '$Barrer_Vesp', '$Trapear_Mat', '$Trapear_Vesp', '$Limpiar_Ventanales_y_Vitrinas', '$Fecha', '$Encargada', '$Supervisora'
WHERE Tienda = '$MiTienda')
ON DUPLICATE KEY UPDATE `Apertura`= '$Apertura', `Cierre_20_00` = '$Cierre_20_00', `Cierre_20_30` ='$Cierre_20_30', `Cierre_21_00`= '$Cierre_21_00', `Sanitarios` ='$Sanitarios', `Barrer_Mat`= '$Barrer_Mat', `Barrer_Vesp`='$Barrer_Vesp' , `Trapear_Mat`='$Trapear_Mat' , `Trapear_Vesp` ='$Trapear_Vesp', `Limpiar_Ventanales_y_Vitrinas`='$Limpiar_Ventanales_y_Vitrinas' , `Fecha`= '$Fecha', `Encargada`='$Encargada' , `Supervisora`= '$Supervisora'");
Current row values are:
Codigo|Tienda|Apertura|Cierre_20_00|Cierre_20_30|Cierre_21_00|Sanitarios|Barrer_Mat|Barrer_Vesp|Trapear_Mat|Trapear_Vesp|Limpiar_Ventanales_y_Vitrinas|Fecha |Encargada|Supervisora
2 |1010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0000-00-00 | 0 | 0
What is wrong with my query? $MiTienda is = 1010 . I tested by adding all other values to 4 and the date with todays date but it doesnt update. I am wondering if I should drop the Code Column and make Tienda PK?
So it turns out that my variables were not being pushed through from the form in the previous page. That is why it stored nothing. I used print_r($_SESSION); in the page with the query above to find out.