我試圖使SQL代碼CI,問題是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);
}
請幫助:)
我應該在哪裏寫$ ID-> id_label? – user1781895
在query3中,您將$ id作爲值插入。 –
$ sql ['query3'] =「INSERT INTO t_publisher(PUBLISHER,ARTIS,ID_LABEL)values('$ user','Various Artist','$ id-> id_label')」; 那樣?我會嘗試..但是,它仍然在數據庫上:( – user1781895