PHP.mk документација

odbc_longreadlen

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.odbc-longreadlen.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.odbc-longreadlen.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
odbc_longreadlen

Референца за `function.odbc-longreadlen.php` со подобрена типографија и навигација.

function.odbc-longreadlen.php

odbc_longreadlen

(PHP 4, PHP 5, PHP 7, PHP 8)

odbc_longreadlenРакување со LONG колони

= NULL

odbc_longreadlen(Odbc\Result $statement, int $length): true

Контролира ракување со LONG, LONGVARCHAR and LONGVARBINARY колони. Стандардната должина може да се постави со користење на uodbc.defaultlrl php.ini directive.

Параметри

statement

ODBC објектот за резултат.

length

Бројот на бајти вратени на PHP се контролира со параметарот length. Ако е поставен на 0, податоците од долгите колони се проследуваат до клиентот (т.е. се печатат) кога се добиваат со odbc_result().

Вратени вредности

Секогаш враќа true.

Дневник на промени

Верзија = NULL
8.4.0 statement очекува Odbc\Result инстанца сега; претходно, а resource се очекуваше.

Белешки

Забелешка:

Ракување со LONGVARBINARY колони исто така е под влијание на odbc_binmode().

Белешки од корисници 6 белешки

php dot net dot notes at webqs dot com
20 години пред
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
deletethis@bjoern(at)syltonline(doot)de
пред 10 години
It's not mentioned in the notes here, but odbc_longreadlen($result, 0); only affects the output from odbc_result().  Setting the read length to 0 (or less than zero) will just output a blank string in the odbc_fetch_object(), odbc_fetch_array() and odbc_result_all() functions
Вредноста за дадената
пред 16 години
I've tried to use a suggestion in the first comment but that didn't actually worked as I would expect... I wanted to get all data no matter how big it is, but strange things happened and I finally found this solution (works fine at least for MS SQL 2000 for at least few MB of binary data):

<?php
// connection
$link = odbc_connect($odbc_source_name, $user, $pass);

// query (note - one row in this example)
$sql = 'SELECT image_data_column FROM some_table WHERE record_id=1';

// run
$result = odbc_exec ($link, $sql)
if (!$result)
{
    trigger_error ('[sql] exec: '.$sql, E_USER_ERROR);
}

// fetch settings
odbc_binmode ($result, ODBC_BINMODE_PASSTHRU); 
odbc_longreadlen ($result, 0);

// get contents
ob_start(); // you would probably need to move this inside if you expect more rows
while (odbc_fetch_row($result))
{
    odbc_result($result, 1); // this actually echos all of the contents of the image_data_column
}
odbc_free_result($result);
$contents = ob_get_clean();
?>
jdcard at inreach dot com
21 години пред
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.
Анонимен
пред 23 години
An alternative is to adjust your php.ini file and set:
odbc.defaultlrl=65536
Or something else sufficiently large.
lrl = long read length
jasendorf at lcounty dot com
yasuo_ohgaki at hotmail dot com
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
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.