PDO
$sth->bindValue(':value', $this->value . "%" , \PDO::PARAM_STR);
=> 想定どおりに動作しない(前方一致にならず、無指定の"%"扱いっぽく検索される)
$search_val = $this->value . "%";
$sth->bindValue(':value', $search_val , \PDO::PARAM_STR);
=> ちゃんと動く。
なんで?
More than 5 years have passed since last update.
PDO
$sth->bindValue(':value', $this->value . "%" , \PDO::PARAM_STR);
=> 想定どおりに動作しない(前方一致にならず、無指定の"%"扱いっぽく検索される)
$search_val = $this->value . "%";
$sth->bindValue(':value', $search_val , \PDO::PARAM_STR);
=> ちゃんと動く。
なんで?
Register as a new user and use Qiita more conveniently