我在發佈之前搜索過,但沒有找到我的問題的答案。在MYSQL中使用PHP變量存儲查詢
我具有其中存儲的查詢,如(與存儲在數據庫中的PHP變量)的數據庫中的表:
select * from accounts where type = 'client'
select * from accounts where user_id = $userid
select * from accounts where name = '$name'
我假定當我把該特定查詢從數據庫PHP將識別該變量並將其替換,但將其視爲常規文本。
有沒有辦法讓PHP替換存在的實際變量$ _ _?我想也許eval()函數可能是?
您從哪裏執行腳本?爲PHP變量工作,你應該執行你的SQL語句在PHP腳本 – 2012-04-24 17:12:42
類似的問題:http://stackoverflow.com/questions/283222/best-way-to-substitute-variables-in-plain-text-using-php – Trevor 2012-04-24 17:13:48