我试图在 CI 中制作 sql 代码,问题是ID_LABEL
在 t_publisher 处填充了 0,它应该填充从 t_label 获取的数字。
$sql['query1'] = "INSERT into t_user (USER_NAME, USER_PASS, USER_STATUS, USER_TYPE) values ('$user', '$pass','1','publisher')";
$sql['query2'] = "INSERT INTO t_label (LABEL) values('$user')";
$id_label = "select id_label from t_label where label ='".$user."'";
$id = $this->db->query($id_label)->result();
$sql['query3'] = "INSERT INTO t_publisher (PUBLISHER, ARTIS, ID_LABEL) values('$user', 'Various Artist', '$id')";
$result = array();
foreach($sql as $key => $value){
$result[$key] = $this->db->query($value);
}
请帮忙 :)