Passing return values from a function to bindParam in PDO
bindParam()
doesn't seem to evaluate a function and then bind its return value to the parameter of the prepar开发者_运维百科ed statement, like so
$stmt->bindParam('foo', bar());
So, in order to get around this, is it good practice to do this instead?
$stmt->bindParam('foo', eval(bar()));
Or is there something else someone out there can recommend doing? Thanks!
Better to use bindValue()
instead of bindParam()
, it can pass values as well:
$stmt->bindValue('foo', bar());
精彩评论