PHP 绑定“bigint"数据类型(MySQLi 准备好的语句) [英] PHP binding 'bigint' datatype (MySQLi prepared statement)
问题描述
$studentId = 57004542323382
$companyOfferId = 7
$sql = 'INSERT INTO studentPlacement (companyOfferId, studentId) VALUES (?, ?)';
if ($stmt = $db->prepare($sql)) {
$stmt->bind_param("ii", $offerId, $studentId);
$stmt->execute();
$insertId = $stmt->insert_id;
$stmt->close();
}
我的问题在于 studentId 变量.它的值太长而无法存储为标准整数,因此必须存储为 bigint.将参数绑定为整数时,它只需输入1"作为 studentId 值.据我了解 bind_param
支持 4 种类型;整数、字符串、blob 和 double.有没有人对我如何解决这个问题有任何想法,以便我可以将值作为 bigint 正确发送?
My problem lies with the studentId variable. Its value is too long to be stored as a standard integer so it must be stored as a bigint. When binding the parameter as an integer it simply enters '1' as the studentId value. To my understanding bind_param
supports 4 types; integer, string, blob and double. Does anybody have any ideas as to how I could get around this problem so I can properly send the value as a bigint?
谢谢
推荐答案
Use $studentId = '57004542323382';//添加引号
和用于绑定的字符串参数.
Use $studentId = '57004542323382'; // quotes added
and string param for binding.
这篇关于PHP 绑定“bigint"数据类型(MySQLi 准备好的语句)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!