Good day to all. The essence of the problem:
$find = '%fish%'; $db = new PDO(подключаемся); $sth = $db->prepare("SELECT id, title, url FROM news WHERE title LIKE ?"); $sth->execute(array($find)); $articles = $sth->fetch(PDO::FETCH_ASSOC);
returns an array of Array ([id] => 12 [title] => fish fish fish [url] => ss.com). But only one line, and not all with similar entries (which are exactly). Tried and Bindvale and Bindparam before the executive, but to no avail. The only effective option was:
$articles = $db->query("SELECT id, title, url FROM news WHERE title LIKE ".$find."");
but it’s not kosher: c
$sth = $db->prepare("SELECT id, title, url FROM news WHERE title LIKE ?"); $sth->execute(array($find)); $articles = $sth->fetch(PDO::FETCH_ASSOC);
This also returns the first row with the entry. Pleased with any comments.