Hi guys, im wondering what the declaration of the data type in the bind parameter (or value) is used for...
I mean, i thougth that if i define a param like int, PDO::PARAM_INT, the param must be converted in int, something like
$delete->bindParam(1, $kill, PDO::PARAM_INT);
//should works like
$delete->bindParam(1, (int)$kill);
or at least throw an error if the param is not the type declared, but is not so.
Googling around, i found that in the php.net archive:
Hi all,
I am currently working on PDO. Exactly on the bindParam() function. The third parameter data_type seems to be here to force the type of the value ? But when I try :
$sql = "INSERT INTO produit (idproduit, nom, marque) VALUES (NULL, :nom, :marque)"; > $stmt = $dbh->prepare($sql); $nom = 'Testarossa'; $marque = 'Ferrari' ; $stmt->BindValue(':marque',$marque) ; $stmt->BindParam(':nom',$nom,PDO::PARAM_INT) ; $stmt->execute(); $nom = '250 GTO' ; $stmt->execute(); ?>
I was expecting to have either a PHP error or an interger in my database. But in my DB I have :
22 Testarossa Ferrari 23 250 GTO Ferrari
It mean that it didn't change if I have the third parameter or not. Or perhaps I miss something. Can someone tole me more ? Or just can someone told me where I can find information about it.
Regards,
Cyruss
that is exactly my situation. Where my thought are wrong?