1

Let x is a column of the table t allowing NULL values.

Which value should $value variable take for the following PDO statement to insert NULL value?

$db->prepare("INSERT t SET x=:x")->execute(array(':x'=>$value));

Sven
  • 66,463
  • 10
  • 102
  • 105
porton
  • 4,928
  • 10
  • 37
  • 76

1 Answers1

2

You simply insert it as null:

$db->prepare("INSERT t SET x=:x")->execute(array(':x'=>null));

If you want, you can also add the data type of PDO::PARAM_NULL.

SeanWM
  • 16,319
  • 7
  • 49
  • 83