对于自增长的主键列不好取值的情况,php提供了一个变量来取值,insert_id
$db = new MySQLi("localhost","root","","z-stu");
$sql = "insert into score values('','103','3-105','90')";
$db->query($sql);
echo $db->insert_id; //取上一次添加数据的主键值
2023-08-27 09:25:40
对于自增长的主键列不好取值的情况,php提供了一个变量来取值,insert_id
$db = new MySQLi("localhost","root","","z-stu");
$sql = "insert into score values('','103','3-105','90')";
$db->query($sql);
echo $db->insert_id; //取上一次添加数据的主键值