postsql with placeholder for php
Posted: Fri Aug 24, 2007 3:14 am
Hello
I have a simple query like:
$dbconn = pg_Connect("dbname=abc user=abc");
$query = "SELECT * FROM subscriber where subscriber.id = $id";
$result = pg_exec($query);
...
It can be seen that I have $id in the query and this is not a good practice. I want to have a placeholder like this:
$query = "SELECT * FROM subscriber where subscriber.id = ?";
How I can rewrite the code above
Many thanks
john
I have a simple query like:
$dbconn = pg_Connect("dbname=abc user=abc");
$query = "SELECT * FROM subscriber where subscriber.id = $id";
$result = pg_exec($query);
...
It can be seen that I have $id in the query and this is not a good practice. I want to have a placeholder like this:
$query = "SELECT * FROM subscriber where subscriber.id = ?";
How I can rewrite the code above
Many thanks
john