I'm trying to do a simple select like this:
$productId = '241';
$stmt = $db->prepare('SELECT * FROM products WHERE id = ?');
$stmt->execute([ $productId ]);
$product = $stmt->fetch(PDO::FETCH_ASSOC);
It works, but if I change productId to this:
$productId = '241FJKSDFJKDSJKF';
it still brings me the product, whereas it should, since it doesn't match. Why is this happening?
I think I get it, id
is primary key, auto increment so non numerical characters are being ignored, still I don't want this behaviour, is there any way to change it?