title: PDOException: SQLSTATE[IMSSP]: Tried to bind parameter number 65536. SQL Server supports a maximum of 2100 parameters
body: <p>Ok so I've come across a really odd PDOException that I cannot seem to get my head around. Here is the exception generated:</p>
  
  <pre><code>PDOException: SQLSTATE[IMSSP]: Tried to bind parameter number 65536.  SQL Server supports a maximum of 2100 parameters. in D:\Work\CEUR16-004\Project\www_root\includes\scripts\php\libCore\products.php:169
  Stack trace:
  #0 D:\Work\CEUR16-004\Project\www_root\includes\scripts\php\libCore\products.php(169): PDOStatement-&gt;execute()
  #1 D:\Work\CEUR16-004\Project\www_root\includes\pages\products\products.php(5): ProductCore-&gt;build_product_list()
  #2 D:\Work\CEUR16-004\Project\www_root\index.php(27): include('D:\\Work\\CEUR16-...')
  #3 {main}
  </code></pre>
  
  <p>And here is the code it refers to:</p>
  
  <pre><code>public function build_product_list()
      {
          // This function builds the product list visible on the main site (guests only)
          try
          {
              if($this-&gt;product_type_id == "999")
              {
                  $query = 'SELECT sp.product_id, sp.product_name, sp.product_price, pt.product_type_name FROM shop_products AS sp LEFT JOIN product_types AS pt ON sp.product_type_id = pt.product_type_id ORDER BY sp.product_type_id ASC'; // Line 161
              }
              else
              {
                  $query = 'SELECT sp.product_id, sp.product_name, sp.product_price, pt.product_type_name FROM shop_products AS sp LEFT JOIN product_types AS pt ON sp.product_type_id = pt.product_type_id WHERE sp.product_type_id = :product_type_id ORDER BY sp.product_id ASC';
              }
              $stmt = $this-&gt;dbcore_prod_core-&gt;dbc-&gt;prepare($query);
              $stmt-&gt;bindParam(':product_type_id', $this-&gt;product_type_id, PDO::PARAM_INT);
              $stmt-&gt;execute(); // Line 169
              // Function continues below...
  </code></pre>
  
  <p>Now, this exception is only generated when <code>$this-&gt;product_type_id</code> is equal to <code>999</code> which runs a query on line 161 (annotated in above code). I have run the query directly on the server and it returns the expected results, so why does PDO throw an exception?</p>