title: why does my SQL execute(select exists) function always returns 1?
body: <p>I can't seem to figure out what's wrong with this PHP code:</p>
  <pre><code>$sql = $db-&gt;prepare(&quot;SELECT EXISTS(SELECT 1 FROM profile WHERE uid = ?)&quot;);  
            $p_already_exists = $sql-&gt;execute([$_SESSION['uid']]);
  </code></pre>
  <p>I'm running the sqlite3 PDO module, and it doesn't matter whether the 'uid' is in the database or not, $p_already_exists is always assigned 1. I'm expecting for it to be 0 if it's not in the database, and 1 if there is at least one record in the database.</p>
  <p>I've double checked that echoing out $_SESSION['uid'] gives me the same value to uid (TEXT) in the database.</p>
  <p>Does anybody know why this isn't working for me? At the end of the day I'm just after an efficient way of returning a boolean value (hence why I'm not using COUNT). Appreciate your help.</p>
  <p>ref <a href="https://stackoverflow.com/questions/4484974/how-to-check-whether-select-exists-returns-a-value-or-not">How to check whether SELECT EXISTS returns a value or not?</a></p>