我正在嘗試執行基於先前查詢中獲取的值的查詢。類似的東西:PHP:將變量轉換爲字符串查詢
$variableid = 100;
$query_prev = "SELECT query FROM queries_table WHERE id = 1";
$result_prev = pg_query($pg,$query_prev);
$row_prev = pg_fetch_array($result_prev);
$final_query = $row_prev['query'];
$row_prev['query'] value would be "SELECT * FROM other_table WHERE id = $variableid";
$final_query value at this point is: "SELECT * FROM other_table WHERE id = $variableid"
/* but that I want is this value: */ "SELECT * FROM other_table WHERE id = 100"
你在數據庫中存儲SQL? **爲什麼**? –
我最好的建議是不要做這個,它是一個可怕的想法。無論你想要實現什麼(不清楚你的問題),相信我還有更好的辦法。 – scav
重要的是馬克b嗎? – fMac