문제

The point is to make a query that will grab values introduced by the user on a input box, and retrieve the database records found trough that keyword comparison.

On a innodb engine, so no MATCH AGAINST available correct ? I will use LIKE on a indexed column table, hope it's ok.

traditionally we will do:

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

So if our query string is AB we will retrieve both: "lab" and "abnormal" precise?

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


Thinking:

Something like,

$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) Could a VO be of any use on this case?

Thanks a lot in advance!

도움이 되었습니까?

해결책

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

Wouldn't this work?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top