I'm building a search function for my site and would like to search in the title and content of the articles.
The query would look like SELECT id FROM articles WHERE title LIKE '%<user input>%' OR content LIKE '%<user input>%';
Is there any way to achieve this with PDO? As I've read, the following is not possible.
$pdo = new PDO('pgsql:host=localhost;dbname=mysite', username, password);
$statement = $pdo->prepare('SELECT id FROM articles WHERE title LIKE :userinput OR content LIKE :userinput');
$search = '%' . $_REQUEST[searchterm] . '%';
$statement->bindParam(':userinput', $search);