Php 如何在mysqli中插入用户的自定义铭文ID?
我正在写学校经理的剧本。 我不知道如何插入订阅的自定义唯一id 我只是使用此功能在显示他/她的数据库完整信息时显示其唯一订阅的id:Php 如何在mysqli中插入用户的自定义铭文ID?,php,mysqli,uniqueidentifier,Php,Mysqli,Uniqueidentifier,我正在写学校经理的剧本。 我不知道如何插入订阅的自定义唯一id 我只是使用此功能在显示他/她的数据库完整信息时显示其唯一订阅的id: $year = date('Y'); $ID = substr($student->dateNaissance,8,10).$student->id_etudiant."/".$year; 该功能由三部分组成: 出生年份的最后两位数字(例如:01/01/1981..i使用substr函数仅取-->81) 数据库表中的行id(例如:50) 以及转载年
$year = date('Y');
$ID = substr($student->dateNaissance,8,10).$student->id_etudiant."/".$year;
该功能由三部分组成:
- 出生年份的最后两位数字(例如:01/01/1981..i使用substr函数仅取-->81)
- 数据库表中的行id(例如:50)
- 以及转载年份(示例:2013年)
if(isset(....){
......
$mysqli->query("INSERT INTO table (a,b,c, ...etc) VALUES('','',''..etc)");
$year = date('Y');
$mysqli_query("SELECT * FROM table_name");
$studentID = $mysqli_insert_id();
$ID = substr($student->dateNaissance,8,10).$ID."/".$year;
$mysqli->query("UPDATE table_name SET id_subscription = $ID");
}
但它不起作用:\
顺便说一下:在我的表中,我使用了一个自动增量id+订阅id,我想在其中插入上面显示的自定义id。假设行id是一个自动增量字段,那么您必须分两个阶段进行:
1.使用mysql\u insert\u id() 如果您想要最后一个id或记录,请使用此
select*from table order by id desc
或使用mysqli_insert_id
或mysqli_insert_id
$mysqli_query
和$mysqli_insert_id()
?不可靠的代码。。希望只是打字错误。不要把代码块放进注释中。完全不可读。您可以编辑问题并附加它。