>>402
普通は、プレースホルダを使う。
http://lets.postgresql.jp/documents/tutorial/with_php/against_sql_injection/placeholder

SQLインジェクションが起きてもいいなら、'where id = ' . $idみたいに、クエリ文字列を組み立てる。