I'm working in a Perl script and I'd like to use named parameters to perform a query in a Postgres database. The DBI documentation says that's not portable:
Some drivers also allow placeholders like :name and :N (e.g., :1, :2, and so on) in addition to ?, but their use is not portable
I'd like to do that anyway. Does anyone know if the Postgres driver implement that?
Instead of performing a query like this:
$q = $pg->prepare($query);
$q->bind_param(1, "value");
$q->bind_param(2, "value");
$q->execute();
I'd like to do something like this:
$q = $pg->prepare($query);
$q->bind_param("parameterX", "value");
$q->bind_param("parameterY", "value");
$q->execute();
Cheers!
EDIT
The correct syntax is as follows (I was missing the colon):
$q = $pg->prepare($query);
$q->bind_param(":parameterX", "value");
$q->bind_param(":parameterY", "value");
$q->execute();