2

The title is a pretty good summary of what's going on. I have a php application built on Zend Framework 2 and running on CentOS using the pdo_dblib driver to connect to an MSSQL server for persistence.

I'm trying to store some rather long strings of encoded data into an nvarchar (max) column in one of the tables and thus far I have proven that I can successfully INSERT the data into the table. I have verified that the data stored is complete and correct by performing a SELECT query via a desktop C# app I wrote for debugging purposes.

However when I run the exact same SELECT query via the ZF2 Adapter (bypassed the query builder for debugging) I receive a truncated response, exactly 2048 characters in length. For reference, the test string is roughly 110kb in length.

I have similar table structures and queries in another app connected to MySql and have never seen this issue.

Any suggestions?

C# select

 using (SqlConnection connection = new SqlConnection(connectionString))
        {
            connection.Open();
            // Do work here; connection closed on following line.
            using (SqlCommand command = new SqlCommand("select data from fil_tab where uid = 10", connection))
            using (SqlDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    int value = reader.GetString(0).Count(); // value gives me the correct char count
                }
            }
        }

The matching php

 public function test(){
    $test = $this->tableGateway->getAdapter()->query("select data from fil_tab where uid = 10");
    $result = $test->execute()->current();
    $value = strlen($result['data']); //2048 every time.
}
BitLagoon
  • 33
  • 5
  • Can you post some relevant code, please? – Hackerman Apr 15 '15 at 18:45
  • edited the main post with an example of the C# select that is working and the php select that is returning a truncated result. – BitLagoon Apr 15 '15 at 18:57
  • I'm more interested in the way your are retrieving the data via web...are you using ajax and the get method?? – Hackerman Apr 15 '15 at 19:03
  • I am just curious. Does the data echo'es correctly? If that is the case, I think maybe it is safe to assume that the adapter reserves 2048 characters for string operations that is being retrieved over a non MySQL database. – Hozikimaru Apr 15 '15 at 19:05
  • No web interaction. This is pure backend php and c#. For php variable inspection is via zend_debug inside php storm. For C# it's all native VS. – BitLagoon Apr 15 '15 at 19:06
  • @Surgeon of Death no, the data is truncated. Any subsequent operation with the result is only able to act upon the 2kb of data. – BitLagoon Apr 15 '15 at 19:11
  • I think this will help. http://stackoverflow.com/questions/13381854/python-truncate-at-255-chars-when-querying-ms-sqlserver-with-freetds .It seems to be the same issue as you may be using FreeTDS based on the Zen/PHP documentation for pdo_dblib – Hozikimaru Apr 15 '15 at 19:51
  • just a guess - worth accessing as a 'lob' column rather than 'varchar'? – Ryan Vincent Apr 15 '15 at 21:44
  • it's best if potential answer are submitted as such so they can be remarked on separately. - so far no luck even after binding as lob. – BitLagoon Apr 15 '15 at 22:46

0 Answers0