【发布时间】:2015-06-26 03:49:35
【问题描述】:
我遇到了这样的问题,我无法获取父表的 id。
table_name : transaction_tbl
- transaction_id
-file_name
-file_path
-description
table_name : transaction_details
-details_id
-transaction_id
- details
这是我要插入的代码:
$sql = "INSERT INTO transaction_tbl (`file_name`,`file_path`,`description`) VALUE('$file_name','$file_path','$description') " ;
$query = $conn->query($sql);
$transaction_id = mysqli_insert_id($conn);
if ($query === True ){
$sql = "INSERT INTO transaction_details (`transaction_id`,`details`) VALUES ($transaction_id,$details) ";
}else {
trigger_error('Wrong SQL: ' . $sql . 'Error: ' . $conn->error, E_USER_ERROR);
}
现在我可以在我的 transaction_tbl 中插入,但不能在 transaction_details 中插入。我该怎么办?有人可以帮帮我吗?
【问题讨论】: