Php mysqli bind_param中NULL的类型是什么?
我试图将参数绑定到MySQLi prepared语句中的INSERT,如果该变量存在,则为INSERT 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 类型变量 i对应变量的类型为integer d对应变量的类型为double s对应的变量具有类型字符串 b对应的变量是blob,将以数据包的形式发送Php mysqli bind_param中NULL的类型是什么?,php,mysqli,sqlbindparameter,Php,Mysqli,Sqlbindparameter,我试图将参数绑定到MySQLi prepared语句中的INSERT,如果该变量存在,则为INSERT 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 an
但是当我插入一个variable=null时,我如何定义变量的类型呢?或者我应该将类型定义为“” 将变量设置为
null
并传递它
$var1 = null;
您不需要将null强制转换为特定的数据类型-Mysqli将处理传递给任何接受的数据类型的null值,因此只需使用每个字段在传递非null值时所具有的类型
$intVar = null;
$doubleVar = null;
$stringVar = null;
$blobVar = null;
$insert_data->bind_param('idsb', $intVar, $doubleVar, $stringVar, $blobVar);
所有这些都是有效的,Mysqli将接受。只需将null作为变量传递,并使用字符串。将变量设置为null(例如,
$var=null;
)。我应该像$var1=null这样编写可能重复的代码$插入数据->绑定参数('s',$var1);或$insert_data->bind_参数(“”,$var1);这并不能回答问题。