简体   繁体   中英

Update ENUM field in MySQL

I have a strange and incomprehensible situation. I can't update an ENUM field with my query in my php script. Executed in Heidi, it works perfectly. Can somebody help me to understand why?

This is the query:

UPDATE ps_specific_price 
SET reduction='0.5', reduction_type='percentage' 
WHERE id_product='249' and id_group='3'

The enum field is reduction_type (amount, percentage)

Here is the code for the operation:

if($valori['perc_riv']==0){
    $sql_perc_riv="update ps_specific_price set reduction='0', reduction_type='amount' where id_product='".$valori[id_product]."' and id_group='3'";
} else {
    $riduzione=(float)$valori['perc_riv']/100;
    $sql_perc_riv="update ps_specific_price set reduction_type='percentage' WHERE id_specific_price='2031'"; // where id_product='".$valori[id_product]."' and id_group='3'";
}
    $sttpercriv = $conn->prepare($sql_perc_riv);
    $sttpercriv->execute();

Ok, I read better the documentation: I have to make an Alter table. I dont' want. I'll make a select, then I'll delete the row and I'll make a new insert with the different values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM