Mysqli到PDO绑定参数

I am switching from mysqli syntax to PDO and having some doubts:

Before I used this (example of binding int, string, decimal values):

$stmt = $conn->prepare("INSERT INTO MyGuests (firstname, id, value) VALUES (?, ?, ?)");
$stmt->bind_param("sid", $firstname, $id, $value);
$stmt->execute();

With PDO I should use this: (here param decimal already doesnt exist, not to mention that I have to write multiple lines for binging)

$stmt = $conn->prepare("INSERT INTO MyGuests (firstname, id, value) VALUES (?, ?, ?)");
$stmt->bindParam(1, $firstname, PDO::PARAM_STR);
$stmt->bindParam(2, $id, PDO::PARAM_INT);
$stmt->bindParam(3, $value, PDO::PARAM_STR);//no decimal type!
$stmt->execute();

Should I just 'forget' about types and do this?

$stmt = $conn->prepare("INSERT INTO MyGuests (firstname, id, value) VALUES (?, ?, ?)");
$stmt->execute([$firstname, $id, $value]);

How can int and decimal fail in this situation?

Yes, most of time you should.

There are only few extremely rare cases where you would have to fall bфck to separate binding. While for the both INT and DECIMAL string binding is all right.

Note that for the decimal type you should be using "s" in mysqli as well.