0

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.

clearly, I want to add id column'value to parent_root column.

   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')."')";
user1702486
  • 107
  • 1
  • 10

2 Answers2

1

If it was MySQL (yes, I know it was more generic) you could use a trigger: MySQL Triggers last_insert_id()

Community
  • 1
  • 1
ethrbunny
  • 10,379
  • 9
  • 69
  • 131
0

You can't do this in the same query--the auto incremented id doesn't exist until the record is inserted. After your query runs in php, grab the last insert id and run an update query.

Ray
  • 40,256
  • 21
  • 101
  • 138