Step 1: Insert without payment_code.
Step 2: Get mysql_insert_id from STEP 1.
Step 3: Update payment_code with where condition as mysql_insert_id.
PHP 中的代码片段:
可能需要更正命令。
1. mysql_query("INSERT INTO payments (date, item, method, payment_code)
VALUES (NOW(), '1 Month', 'paypal')");
2. printf("Last inserted record has id %d\n", mysql_insert_id());
3. mysql_query(“UPDATE payments set payment_code=CONCAT("chaminda",mysql_insert_id()) where id=mysql_insert_id());
这是一种方法。
PHP 中的代码片段: 可能需要更正命令。
尝试这个 :