You Don't. Here's why:
If using $dbh->query(...)
you can just call sql with the parameters interpolated into the sql string. By using a query like
$dbh->query("INS INTO MY_TABLE_OF_NAMES ('$name');");
10 or so years ago, this is how most sql was done. This is the most straight forward way of invoking the database, using the SQL interface alreaady implemented by the RDMS, without the need for a special lower level interface. But people discovered that this was dangerous because of something called sql injection.
http://en.wikipedia.org/wiki/Sql_injection
The simplest and most common example goes something like this. Suppose you had a sql call in your web page that would run:
INS INTO MY_TABLE_OF_NAMES VALUE ('$name');
But then someone would come to your site and enter there name as bob'); DROP TABLE MY_TABLE_OF_NAMES;
suddenly your interpolated sql statement becomes
INS INTO MY_TABLE_OF_NAMES VALUE ('bob'); DROP TABLE MY_TABLE_OF_NAMES; );
which would subsequently insert bob into your database, delete all of your names, and throw an error for the trailing );
when your website ran it.
So, prepared statements were invented. Instead of interpolating string directly into your strings it will use ?
chars to denote dynamic values, and a bind
function is used to insert the string safely. This way manevolent input will never be interpreted as SQL code by your database engine and you site cant be tricked into doing things it doesnt want to do. The prepare command takes a sql string takes a bit of sql and semi compiles into a lower level database langauge leaving spaces open of dynamic strings wherever a ?
is used. Bind then takes one of those open spaces and fills it with a piece of data, encoded to escaped ascii, so that it cannot be misinterpreted as SQL code. Once all of those ?
s are filled, the sql is ready to be sent to the RDMS to be run.
So to answer your question, you will never bind a parameter to a simple query. If you want dynamic varables in a simple query you will just interpolate them into the SQL string. But this is dangerous. Prepared statements allow you to precompile a sql statement then safely bind dynamic parameters to it to create safe dynamic SQL. Binding to sql is purely a construct of prepared statements.