Get the generated uuid after insert php

前端 未结 4 1773
一生所求
一生所求 2020-12-09 12:33

i have a table field type varchar(36) and i want to generate it dynamically by mysql so i used this code:

$sql_code = \'insert into table1 (id, text) values          


        
4条回答
  •  一生所求
    2020-12-09 13:01

    1. char(36) is better
    2. you cannot. The only solution is to perform 2 separated queries:

      • SELECT UUID()
      • INSERT INTO table1 (id, text) VALUES ($uuid, 'text')

    where $uuid is the value retrieved on the 1st step.

提交回复
热议问题