Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- const USER = 'test';
- const PASS = 'test';
- try {
- $dbh = new PDO('mysql:host=localhost;dbname=test', USER, PASS, [
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- ]);
- $sql = '';
- $sql .= "SELECT * FROM demo WHERE 1=1 ";
- $sql .= "AND hint LIKE :f1 ESCAPE '/' ";
- $sql .= "OR hint LIKE :f2 ESCAPE '/' ";
- $sth = $dbh->prepare($sql);
- $sth->bindValue(':f1', '2XXXX4/_%');
- $sth->bindValue(':f2', '%/_2XXXX4/_%');
- $sth->execute();
- $result = $sth->fetchAll();
- echo "<pre>" .print_r($result, true). "</pre>";
- $dbh = null;
- } catch (PDOException $e) {
- print "Error!: " . $e->getMessage() . "<br/>";
- die();
- }
Add Comment
Please, Sign In to add comment