PHP: odbc_longreadlen - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

odbc_next_result odbc_gettypeinfo

Last updated: Fri, 26 Jan 2007

view this page in

# odbc_longreadlen

(PHP 3 >= 3.0.6, PHP 4, PHP 5)

odbc_longreadlen -- Handling of LONG columns

## Description

bool odbc_longreadlen ( resource result_id, int length )

(ODBC SQL types affected: LONG, LONGVARBINARY) The number of bytes returned to PHP is controlled by the parameter length. If it is set to 0, Long column data is passed through to the client.

> Замечание: Handling of LONGVARBINARY columns is also affected by odbc_binmode().

add a note User Contributed Notes
odbc_longreadlen
Paul Schmidinger
30-Aug-2005 05:44
`In my current situation, odbc_binmode(), odbc_longreadlen() and the lrl-setting in the php.ini do not help. But when I remove the DISTINCT from my SELECT-query, it works. I guess in my case DISTINCT truncates the data somehow. Hope that helps someone.
Paul`
php dot net dot notes at webqs dot com
06-Aug-2005 06:12
`Hi
If you are experiencing troubles with truncated and/or strangely encoded data when using PHP with MS SQL via ODBC try setting odbc.defaultlrl ( in php.ini or via ini_set() ) to a largish number, say 65536, as stated in the other notes here.
The trick is to know how long your data is going to be, so you may want to provide some overhead. Unfortunately you have to know how long your piece of string is before you cut it.
Doing this will allow your app to read up to this amount in one go. I'm sure there is a reason for this behaviour but I hadn't experienced anything like it in 5 years of MySQL and Postgres development.
If you still experience problems AND are using unicode data in the long column of your table, make sure it is set to type "ntext", if it is "text". MSDN has some info on data types for Unicode data.
This caused about 3 days of headaches for me, "binary" data crashing browsers and cyclical result sets (i.e repeating data after odbc.defaultlrl bytes).
This fix was only found by poking things with sticks.
HTH`
jdcard at inreach dot com
08-Dec-2004 09:37
`I was reading from a MEMO field (long varchar) in MSAccess, but the data was consistently truncated at 255 characters. I tried all the combinations of odbc_longreadlen() and odbc_binmode() (and odbc.defaultlrl) that I could think of but none of them resolved the problem.
The only fix that worked was to modify my query from "SELECT Field1, Field2 FROM TableName" to "SELECT * FROM TableName".
I suspect that you could cast the field to force the appropriate data type, but when it finally worked after three days of struggle I didn't even try.`
25-Sep-2002 05:00
`An alternative is to adjust your php.ini file and set:
odbc.defaultlrl=65536
Or something else sufficiently large.
lrl = long read length`
buzz77 at gmx dot net
23-Nov-2001 02:31
`Aaargh!
I was wondering about truncated data when reading from a TEXT (LONG VARCHAR) column.
With this I was able to increase the buffer size...`
jasendorf at lcounty dot com
13-Dec-2000 04:26
`I had a heck of a time figuring out what to do with this function. Here's a little piece of code from Jason Lee which I found that might help someone else...
$cur = odbc_exec($cnx, $query);
if(!$cur) {
/* error handler */
}
odbc_binmode($cur, ODBC_BINMODE_PASSTHRU);
odbc_longreadlen($cur, 16384); /* Allow 16kb thru */
while(odbc_fetch_row($cur)) {
$bigger_than_4096_var = odbc_result($cur, 1);
/* etc... */
Hope this helps someone, John`
add a note
odbc_next_result odbc_gettypeinfo

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST