title: Select single column from a row in Laravel?
body: <p>How can I fetch a single column from a single row in Laravel 4?</p>
  
  <p>Here's what I'm trying:</p>
  
  <pre><code>return DB::selectOne("
      SELECT EXISTS(
          SELECT *
          FROM permissions p
              JOIN role_permissions rp ON rp.permission_id=p.id
              JOIN user_roles ur ON ur.role_id=rp.role_id
          WHERE ur.user_id=? AND p.code=?
      )
      ",[Auth::user()-&gt;id,$perm_code]);
  </code></pre>
  
  <p><code>selectOne</code> returns this ugly object though:</p>
  
  <pre><code>object(stdClass)#297 (1) {
    ["EXISTS(
                  SELECT *
                  FROM permissions p
                      JOIN role_permissions rp ON rp.permission_id=p.id
                      JOIN user_roles ur ON ur.role_id=rp.role_id
                  WHERE ur.user_id=? AND p.code=?
        "]=&gt;
    string(1) "0"
  }
  </code></pre>
  
  <p>Is there something better?</p>
  
  <hr>
  
  <p>Using PDO is ugly too:</p>
  
  <pre><code>$stmt = DB::getPdo()-&gt;prepare("
      SELECT EXISTS(
          SELECT *
          FROM permissions p
              JOIN role_permissions rp ON rp.permission_id=p.id
              JOIN user_roles ur ON ur.role_id=rp.role_id
          WHERE ur.user_id=? AND p.code=?
      )
      ");
  $stmt-&gt;execute([Auth::user()-&gt;id,$perm_code]);
  return (bool)$stmt-&gt;fetchColumn();
  </code></pre>