[英]how can i add primary key value which is auto incremented to another column in php?
I have a tree and I want to I have a table which has an id also, I want to use this id by adding to another column. 我有一棵树,我想有一个也有ID的表,我想通过添加到另一列来使用此ID。
clearly, I want to add id column'value to parent_root column. 显然,我想将id列的值添加到parent_root列。
sql = "INSERT INTO agac_menu (id,isim,aciklama,parent_id,parent_root,yetki,sira,tip,created)
VALUES (NULL,'".$isim."','".$aciklama."','".$parent_id."','".$parent_root."','".$yetki."','".$sira."','".$tip."','".date('Y-m-d H:i:s')."')";
如果是MySQL(是的,我知道它更通用),则可以使用触发器: MySQL触发器last_insert_id()
You can't do this in the same query--the auto incremented id doesn't exist until the record is inserted. 您不能在同一查询中执行此操作-自动增量ID在插入记录之前不存在。 After your query runs in php, grab the last insert id and run an update query.
在php中运行查询后,获取最后一个插入ID并运行更新查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.