PHP mysql PDO refuses to set NULL value

后端 未结 2 1830
無奈伤痛
無奈伤痛 2020-12-30 07:08

I am unable to set a nullable field with a default value of null to null using mysql pdo. I can do it using straight sql.

I have tried: (mostly from this question Ho

2条回答
  •  臣服心动
    2020-12-30 07:14

    I will strong recommend to first assign all parameters to variables and then pass those variables to the bindParam() method.

    You can assign by passing NULL to those variables and it will work fine.

    $myVar = NULL;
    $conn->bindParam(':param1' , $myVar , PDO::PARAM_STR);
    

    All the way from Pakistan :)

提交回复
热议问题