How to do SELECT LIKE with PDO Prepare Statement - are objects of value of any use here?

The goal is to make a query that will capture the values ​​entered by the user in the input field and retrieve the database entries found as a result of comparing keywords.

On the innodb engine, so there is no MATCH AGAINST available correctly? I will use LIKE in the indexed column table, hope this is normal.

traditionally we will do:

SELECT our_column FROM our_db_table WHERE our_column LIKE '%$queryString%';

So, if our query string is AB, will we get both: “laboratory” and “abnormal” exact?

1) How can we achieve this, but using PDO?


Thinking:

Sort of,

$stmt = $this->_dbh->prepare("SELECT d.our_column FROM our_db_table d WHERE d.our_column LIKE ?");

But what's next?

Normally I would do:

$stmt->bindParam(1, $ourTableVo->getOurColumn(), PDO::PARAM_STR, 255);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_OBJ);

2) VO ?

!

+3
1
$stmt->bindValue(1, '%' . $ourTableVo->getOurColumn() . '%', PDO::PARAM_STRING);

?

+3

Source: https://habr.com/ru/post/1761745/


All Articles