title: PHP PDO::bindParam() data types.. how does it work?
body: <p>I'm wondering what the declaration of the data type in <a href="http://php.net/manual/en/pdostatement.bindparam.php" rel="noreferrer"><code>bindParam()</code></a> (or <a href="http://php.net/manual/en/pdostatement.bindvalue.php" rel="noreferrer"><code>bindValue()</code></a>) is used for...</p>
  
  <p>I mean, I thought that if I define an integer argument (<code>PDO::PARAM_INT</code>), the argument must be converted to an integer, something like</p>
  
  <pre><code>$delete-&gt;bindParam(1, $kill, PDO::PARAM_INT);
  // should work like
  $delete-&gt;bindParam(1, (int)$kill);
  </code></pre>
  
  <p>or at least throw an error if the argument is not of the declared type. But this is not the case.</p>
  
  <p>Googling around, I found that in the php.net archive:</p>
  
  <blockquote>
    <p>Hi all,</p>
    
    <p>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 :</p>
  
  <pre><code>$sql = "INSERT INTO produit (idproduit, nom, marque) VALUES (NULL, :nom, :marque)";
  $stmt = $dbh-&gt;prepare($sql);
  $nom = 'Testarossa'; $marque = 'Ferrari' ;
  $stmt-&gt;BindValue(':marque',$marque) ;
  $stmt-&gt;BindParam(':nom',$nom,PDO::PARAM_INT) ;
  
  $stmt-&gt;execute(); $nom = '250 GTO' ;
  $stmt-&gt;execute(); ?&gt;
  </code></pre>
    
    <p>I was expecting to have either a PHP
    error or an interger in my database.
    But in my DB I have :</p>
    
    <p>22 Testarossa Ferrari 23 250 GTO
    Ferrari</p>
    
    <p>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.</p>
    
    <p>Regards,</p>
    
    <p>Cyruss</p>
  </blockquote>
  
  <p>That is exactly my situation. Where are my thoughts going wrong?</p>