title: PHP PDO with IN clause and LIMIT
body: <p>I'm trying to execute statement with IN clause using PDO and with LIMIT.</p>
  
  <p>Following this tutorial <a href="https://phpdelusions.net/pdo#in" rel="nofollow noreferrer">https://phpdelusions.net/pdo#in</a> I've managed to build code that is working, but doesn't retrieve data as it should</p>
  
  <pre><code>        $inStmt = DB::prepare("SELECT following_user_id FROM following WHERE user_id=?");
          $inStmt-&gt;execute([$userId]);
          $arr = ($inStmt-&gt;fetchAll(PDO::FETCH_NUM));
          $array = array();
          foreach ($arr as $element ) {
              $array = array_merge($array, $element);
          }
          $in  = str_repeat('?,', count($array)) . '?';
  
          $params = array_merge($array,[$userId]);
          $sql = "SELECT * FROM user_tweets WHERE user_id IN ($in) ORDER BY tweet_date DESC LIMIT 20 OFFSET ?";
          $stmt = DB::prepare($sql);  
          for ($x = 0; $x &lt;= count($params) - 1; $x++) {
              $param = $params[$x];
              echo " ID:" .($x+1) . " PARAM:". $param;
              $stmt-&gt;bindParam(($x+1),$param);
          } 
          $param = (int)$startFrom;
          echo " ID:" .(count($params)+1) . " PARAM:". $param;
          $stmt-&gt;bindParam((count($params)+1),$param,PDO::PARAM_INT);
          $stmt-&gt;execute();
          return $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
  </code></pre>
  
  <p>For example first statement returns array of <code>[43,42]</code>. Then I merge it with 53 so I got <code>[43,42,53]</code></p>
  
  <p>These are the echoes from this example </p>
  
  <pre><code>ID:1 PARAM:42 ID:2 PARAM:41 ID:3 PARAM:53 ID:4 PARAM:0
  </code></pre>
  
  <p>Query also creates as it should: </p>
  
  <pre><code>SELECT * FROM user_tweets WHERE user_id IN (?,?,?) ORDER BY tweet_date DESC LIMIT 20 OFFSET ?
  </code></pre>
  
  <p>What is wrong with my code? I'm confused because everything should be fine (when I call my database with already set variables like below it does return couple rows so it should be working also with PDO but returns nothing)</p>
  
  <pre><code>SELECT * FROM user_tweets WHERE user_id IN (42,41,53) ORDER BY tweet_date DESC LIMIT 20 OFFSET 0
  </code></pre>