When passing named parameters of the form :name
to PDOStatement::bindParam()
, it seems to work whether or not the leading colon is used.
i.e. either this:
$statement->bindParam(':name', $var);
or this:
$statement->bindParam('name', $var);
seems to work.
Here's the documentation for PDOStatement::bindParam()
parameter
Parameter identifier. For a prepared statement using named placeholders, this will be a parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the 1-indexed position of the parameter.
Does this mean the colon can be left off?
bindParam
. The PDO function is probably less strict here as it can define it's own interface to name the parameter.