[freetds] select returns a " " character instead of ""

Martin Rode martin.rode at programmfabrik.de
Wed Apr 5 14:00:20 EDT 2006


hi everybody,

i have found another problem, this time with a current version of php:

client:
* debian linux
* php 5.1.2
* tds 0.63 (debian unstable)

server:
* using microsoft sql server express 9.0.1399 on windows xp2

this following script. it should return a length of 0 for the string 
data, but it returns 1.

i see the same problem with the php/sybase_* api.

--------------------------------
test_query2();


function test_query2() {
    $dsn ="DRIVER={FreeTDS};SERVER=thepope;DATABASE=test";
    $link2 = odbc_connect($dsn , 'sa', 'test' ) or die(odbc_errormsg() );
    odbc_autocommit($link2, true);
    odbc_exec($link2, "
IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE 
TABLE_NAME = 'images') DROP TABLE [images];\n;
CREATE TABLE images (
   name varchar(50),
   data varchar(max)
);
");
    $ins = "INSERT INTO images (name,data) VALUES ('henk','')";
    odbc_exec($link2, $ins);

    $sql = "SELECT data,datalength(data) as length FROM images";
    $res = odbc_exec($link2, $sql);
    $row = odbc_fetch_array($res);
    echo "<pre>";
    print_r($row);
    print_r("STRLEN of 'data':".strlen($row[data]));
    // this prints a length of 1, but it should be 0
}



More information about the FreeTDS mailing list