开发者

Passing return values from a function to bindParam in PDO

开发者 https://www.devze.com 2023-01-30 04:54 出处:网络
bindParam() doesn\'t seem to evaluate a function and then bind its return value to the parameter of the prepar开发者_运维百科ed statement, like so

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());
0

精彩评论

暂无评论...
验证码 换一张
取 消