title: Reading boolean correctly from Postgres by PHP
body: <h2>The main problem of this thread is moved to <a href="https://stackoverflow.com/questions/1314869/to-have-boolean-type-in-postgres-for-php">here</a> about boolean datatype in PHP / Postgres.</h2>
  <p>The problem is the <strong>conversion of <code>t</code> and <code>f</code> to <code>true</code> and <code>false</code>, since  Postgres stores <code>true</code> and <code>false</code> as such.</strong></p>
  <hr />
  <p><strong>How can you use the variable <code>a_moderator</code> in SESSION?</strong></p>
  <p>I fetch the value of the variable <code>a_moderator</code> by</p>
  <h1>#1 code of how I get the variable</h1>
  <pre><code>    $result = pg_prepare($dbconn, &quot;moderator_check_query&quot;, 
          &quot;SELECT a_moderator 
          FROM users
          WHERE email = $1;&quot;
      );
      $a_moderator = pg_execute($dbconn, &quot;moderator_check_query&quot;, array($_SESSION['login']['email']));
  
      $rows = pg_fetch_all ( $a_moderator );
    
      foreach ( $rows as $row ) {
         $_SESSION['login']['a_moderator'] = $row['a_moderator'];
      } 
  </code></pre>
  <p>I use it unsuccessfully by</p>
  <h1>#2 code of how I use the variable unsuccessfully</h1>
  <pre><code>if ( $_SESSION['login']['a_moderator'] == 't' ) {
     // do this
  }
  </code></pre>
  <p>I also ran unsuccessufully the values such as <code>true</code> in the place of <code>t</code>.
  The variable in the SESSION has the value <code>f</code> such that</p>
  <h1>#3 Output which tells me he value of the varibale</h1>
  <blockquote>
  <pre><code>Array ( [login] =&gt; Array ( 
     [passhash_md5] =&gt; dd2f85814c35fd465c30b1472f5d3af8 
     [email] =&gt; nthoaeuntht@Thnatuh.comn 
     [logged_in] =&gt; 1 [user_id] =&gt; 13 
     [username] =&gt; oeauoeh 
     [a_moderator] =&gt; t ) 
  )
  </code></pre>
  </blockquote>