php – mysqli bind_param中的NULL类型是什么?

前端之家收集整理的这篇文章主要介绍了php – mysqli bind_param中的NULL类型是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图将params绑定到INSERT INTO MySQLi预处理语句,如果该变量存在,否则插入null.然后我知道
type    variable
i   corresponding variable has type integer
d   corresponding variable has type double
s   corresponding variable has type string
b   corresponding variable is a blob and will be sent in packets

但是当我插入一个变量= null时,我如何定义变量的类型?或者我应该定义类型”?

您不需要将null转换为特定的数据类型 – MysqLi将处理传递给任何接受的数据类型的空值,因此只要使用每个字段在传递非空值时所具有的类型.
$intVar = null;
$doubleVar = null;
$stringVar = null;
$blobVar = null;

$insert_data->bind_param('idsb',$intVar,$doubleVar,$stringVar,$blobVar);

所有这些都是有效的,并将被MysqLi接受.

猜你在找的PHP相关文章