我正试图使用此方法将参数绑定到它们的特定类型:
mysqli_stmt_bind_param(mysqli_stmt-stmt,字符串类型,mixed&var1[,mixed&…])
我知道第二个参数是
* s is for strings
* d is for decimals
* i is for integers
* b is for blob
我不确定"斑点"是什么。
现在我的问题是,如何将布尔型变量绑定到这个方法中?有这样的方法吗?
下面是更多信息。以下是我的变量:(房型、房价、房间数量、床位数、吸烟人数、无障碍房间)
roomType: string coming from web form
roomPrice: decimal coming from a web form
roomQty: integer coming from web form
numBeds: integer coming from web form
smokingAvail: Boolean coming from web form
accessibleRm: Boolean coming from web form
您可以对所有类型使用string
。Mysql会把它们整理出来。
要传递布尔值,还应该使用i:如果你传递字符串,它总是认为它不等于false(在布尔值的情况下,除非你传递空字符串)
$stmt = $mysqli->prepare ('some query');
$stmt->bind_param("dsi",$price,$name,$sex);
和传递整数i对于十进制d