CodeIgniter Forums

Full Version: mssql - active records - field lengths
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Keeshond Loekie[/eluser]
I'm using the mssql driver to connect to the database...

Current issue is that the fields in the result set are being truncated to 255...

as far as I have been able to trace it might not be an issue with codeigniter itself.

Quote: function _fetch_assoc()
return mssql_fetch_assoc($this->result_id);

the mssql_fetch_assoc returns the record with the fields already truncated.

I'm just wondering if someone else already has had the same issue and was able to resolve it.

Anyway, I was hoping someone could give some ideas on how to investigate and solve the issue.


El Forum

[eluser]Keeshond Loekie[/eluser]
I have found the cause of the issue and the solution:

Quote:marc at NOSPAM dot durdin dot net
19-Nov-2004 04:19
Buried away in the mssql_field_length documentation is an important limitation that it is certainly worth knowing about *BEFORE* you do any database design:

Note to Win32 Users: Due to a limitation in the underlying API used by PHP (MS DbLib C API), the length of VARCHAR fields is limited to 255. If you need to store more data, use a TEXT field instead.

SQL Server natively supports VARCHAR up to 8000 characters. Note that TEXT fields have substantially poorer performance (and are much more limited) than VARCHAR so you may want to design your databases accordingly...

You can also work around this limitation with the following:

-- for example, with MyVarCharField VARCHAR(1000)