PHP bindValue と bindParam
2020/5/7
PDOStatement::bindParam — 指定された変数名にパラメータをバインドする
PDOStatement::bindValue — 値をパラメータにバインドする
$stm = $pdo->prepare("select * from users where user = :user");
$user = "jack";
//
$stm->bindParam(":user",$user);
//エラー
//$stm->bindParam(":user","jack");
$stm->bindValue(":user",$user);
$stm->bindValue(":user","jack");
2020/5/8
bindValue と 「?」
<?php
/* バインドされた PHP 変数によってプリペアドステートメントを実行する */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < ? AND colour = ?');
$sth->bindValue(1, $calories, PDO::PARAM_INT);
$sth->bindValue(2, $colour, PDO::PARAM_STR);
$sth->execute();
?>
Author And Source
この問題について(PHP bindValue と bindParam), 我々は、より多くの情報をここで見つけました https://qiita.com/BohanXIXIXI/items/a30dea56016475cd2aa7著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .