title: Handle boolean input in PHP PDO postgres?
body: <p>Is there a better way to handle boolean inputs for <strong>postgres</strong> PDO driver in PHP?</p>
  
  <p>In PHP PDO casts boolean <strong>false</strong> to "" and <strong>true</strong> to "1". And this causes an error like this in some statements:</p>
  
  <pre><code>00000 - 7 - ERROR:  invalid input syntax for type boolean: ""
  </code></pre>
  
  <p>I am passing my variables to PDOStatement::execute as input array.</p>
  
  <p>For now I am using this workaround to pass appropriate string</p>
  
  <pre><code>':somevar'    =&gt; ($this-&gt;somevar === true ? 'true' : 'false')
  </code></pre>
  
  <p>Is there a better way?</p>
  
  <p>I know about PDOStatement::bindParam with explicit data_type. I want to know the options for passing boolean in params array to the PDOStatement::execute().</p>
  
  <p><strong>UPDATE: added exact code</strong></p>
  
  <pre><code>$qparams = array(
      ':id'            =&gt; $this-&gt;id,
      ':somevar'       =&gt; ($this-&gt;somevar === true ? 'true' : 'false'),
      ':updated_on'    =&gt; $timestamp
  );
  
  $sql = 'UPDATE ' . SONG_ARTISTS . ' SET ' .
      'id = :id, ' .
      'somevar = :somevar, ' .
      'updated_on = :updated_on ' .
      ' WHERE ' .
      ' id = :id';
  
  $stmt = $pdo_handle-&gt;prepare($sql);
  $result = $stmt-&gt;execute($params);
  </code></pre>