title: mssql_bind in PHP truncates string
body: <p>I'm using <code>FreeTDS</code> to connect and work with a SQL Server 2008 database from PHP 5.3.15 on Linux. I have a column in this database that has a datatype of <code>VARCHAR(MAX)</code>.</p>
  
  <p>Unfortunately, I'm having trouble setting the value of the column via <code>mssql_bind()</code> when the value is is over 8000 characters. The value gets stored in the database, but is truncated at 8000 characters. The stored procedure that I'm calling has set the input variable as the proper datatype (<code>VARCHAR(MAX)</code>).</p>
  
  <p>Here is what I've tried:</p>
  
  <ul>
  <li>in php.ini I have set both <code>mssql.textlimit</code> and <code>mssql.textsize</code> to their maximum allowed values (2147483647). It seems that no matter what I set these to they actually have no affect on the size of the text I can send through. That is, even setting these to a value of, say, 100, does not truncate the text at 100 characters.</li>
  <li>setting <code>mssql.textlimit</code> and <code>mssql.textsize</code> using <code>ini_set()</code>. Again, this seems to have no affect.</li>
  <li>setting the <code>maxlen</code> attribute of <code>mssql_bind()</code> to a number higher than 8000. As with the above, even setting this to a lower number seems to have no affect.</li>
  <li>changing the datatype of the column to <code>TEXT</code> and/or changing the <code>type</code> attribute of <code>mssql_bind()</code> to <code>SQLTEXT</code>.</li>
  </ul>
  
  <p>Additionally, to make matters more confusing (to me at least), I <strong><em>can</em></strong> get the entire string length to be stored in the database through the following means:</p>
  
  <ul>
  <li>in my stored procedure hard coding the length of the value of a variable declared as <code>VARCHAR(MAX)</code> to more than 8000 characters. This successfully stores the entire string.</li>
  <li>not using a stored procedure, but instead just executing a query directly in PHP as: <code>"UPDATE my_table SET my_large_colmn = '{$text_longer_than_8000_chars}'"</code>. This successfully stores the entire string.</li>
  </ul>
  
  <p>So this is how I believe I've narrowed it down to the <code>mssql_bind()</code> method truncating the length to 8000 characters.</p>
  
  <p>Is this simply a limitation of <code>mssql_bind()</code> and the <code>FreeTDS</code> driver in PHP or am I missing something?</p>