Very strange behaviour. Using PHP 7.
When I run this query:
$sql = "SELECT * FROM product WHERE model = 'prefix_17867'";
$db_res = $db->query($sql);
$db_row = $db_res->fetch(PDO::FETCH_ASSOC);
print_r($db_row);
An array is printed with the fetched row.
Array ( [product_id] => 18108 [model] => prefix_17867 [quantity] => 10 [price] => 51.5574 )
However, if I concatenate a string (which will result in exactly the same string) no results seem to be fetched from database.
$prfx = "prefix_" . $code;
$sql = "SELECT * FROM product WHERE model = '".$prfx."'";
$db_res = $db->query($sql);
$db_row = $db_res->fetch(PDO::FETCH_ASSOC);
print_r($db_row);
I echoed the query in both cases and comparing it they are exactly the same. Whats the problem? Maybe PDO doesn't let you concatenate in this way?