PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #51

SQL Server 2000 Text column problem

Details

Submitted2003-10-01 03:55 UTC
Fromsaran at inra dot co dot th
Assigneddanielc
StatusClosed
PackageDB
PHP Version4.3.3
OSWindows 2000
Roadmaps(Not assigned)

Comments

[2003-10-01 03:55 UTC] saran at inra dot co dot th

Description:
------------
fetch*() functions cannot handle SQL Server 2000 Text column data correctly. It will repeat the first chunk (4,096 bytes) of the data with some unreadable characters of about 6,000 bytes long until it reach the full length of the actual data.

Reproduce code:
---------------
$dsn = "odbc://$user:$pass@$db_name";
$db = DB::connect($dsn);
$qs="select textdata from table where id=1";
$rs=$db->query($qs);
while($data=$rs->fetchRow()){
echo $data[0];
}
$rs->free();

Expected result:
----------------
This is the begining of 20,000 bytes text data store in MS SQL Server 2000
..
This is the second part (4,097th byte) of the data..
..
..
..
This is the end part of the data.

Actual result:
--------------
This is the begining of 20,000 bytes text data store in MS SQL Server 2000 ..(up to 4,096th byte)
((((((((((((((((((((((((((((((((((((((((((((((unreadable character here, most of them are 0x00 character, about 6,000 bytes long, and then repeated with the first section of data again and again ))))))))))))))))))))))))))))))))))))))))))))

This is the begining of 20,000 bytes text data store in MS SQL Server 2000 ..(up to 4,096th byte)
((((((((((((((((((((((((((((((((((((((((((((((unreadable character here, most of them are 0x00 character, about 6,000 bytes long, and then repeated with the first section of data again and again ))))))))))))))))))))))))))))))))))))))))))))
..
..

[2003-10-01 07:00 UTC] saran at inra dot co dot th

Sorry, please except my apologize. The problem I've found is with NTEXT column not TEXT column which I've quoted which is PHP doesn't recognized.

However, after casting the NTEXT to TEXT datatype, I still cannot fetch data exceeding 4,096 bytes from that TEXT field. Is there any option in order to fetch all data from a single TEXT field exceeding 4,096 bytes using PEAR DB?

[2003-10-01 10:36 UTC] saran at inra dot co dot th

Yes, I can fetch TEXT data from native PHP function like an example function:

-------------------------------------------------------function odbc_mssql_fetch_data_assoc($rs){
$fields=odbc_num_fields($rs);
for($i=1;$i<=$fields;$i++){
$field_name=odbc_field_name($rs,$i);
if(strtolower(odbc_field_type($rs,$i))=='text'){
// if this is a text column, dig it up
while($chunk=odbc_result($rs,$i))$data.=$chunk;
$array[$field_name]=$data;
}else{
// if not, just single fetch
$array[$field_name]=odbc_result($rs,$i);
}
return $array;
}
-------------------------------------------------------