PHP binding 'bigint' datatype (MySQLi prepared statement)

旧街凉风 提交于 2021-01-27 07:08:56

问题


$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();
}

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?

Thanks


回答1:


Use $studentId = '57004542323382'; // quotes added and string param for binding.



来源:https://stackoverflow.com/questions/19908292/php-binding-bigint-datatype-mysqli-prepared-statement

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!