13
ためbindParamでLIKEを使用すると、これが正しい方法だろうaで始まるユーザー名と一致するか?私はこれらのクエリを記述する必要がありますどのように複数の例を読んだが、私は、この特定の<code>bindParam</code></p> <p>を使用したときに実行したいもらうのに苦労していますMySQLのPDOクエリ
$term = "a";
$term = "'$term%'";
$sql = "SELECT username
FROM `user`
WHERE username LIKE :term
LIMIT 10";
$core = Connect::getInstance();
$stmt = $core->dbh->prepare($sql);
$stmt->bindParam(':term', $term, PDO::PARAM_STR);
$stmt->execute();
$data = $stmt->fetchAll();
サンプルコードは次のとおりです。https://gist.github.com/arsho/a203e7bc156ea566587361a76038f020 – arsho