php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43043 NULL == '' for ntext and nvarchar(max)
Submitted: 2007-10-19 18:51 UTC Modified: 2007-10-21 15:30 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: alan dot trick at twu dot ca Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 5.2.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 43 = ?
Subscribe to this entry?

 
 [2007-10-19 18:51 UTC] alan dot trick at twu dot ca
Description:
------------
This bug is somewhat related to #39213 except it only occurs (as far as I can tell) on fields that are ntext and nvarchar(max). The Moodle bug report MDL-11810 (http://tracker.moodle.org/browse/MDL-11810) has more info. This is with freeTDS.

Reproduce code:
---------------
$tables = array(
    'nulltest' => 'varchar(5)',
    'nulltestnvar' => 'nvarchar(5)',
    'nulltestntext' => 'ntext',
    'nulltestnvarmax' => 'nvarchar(max)'
);
foreach($tables as $table=>$domain) {
    print "==$table==\n";
    mssql_query("create table $table (test $domain);");
    mssql_query("insert into $table values('');");
    $r = mssql_query("select * from $table;");
    while ($a = mssql_fetch_assoc($r)) var_dump($a['test']);
    mssql_query("drop table $table;");
}

Expected result:
----------------
==nulltest==
string(0) ""
==nulltestnvar==
string(0) ""
==nulltestntext==
string(0) ""
==nulltestnvarmax==
string(0) ""

Actual result:
--------------
==nulltest==
string(0) ""
==nulltestnvar==
string(0) ""
==nulltestntext==
NULL
==nulltestnvarmax==
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-19 21:47 UTC] felipensp at gmail dot com
This isn't a bug.
Check the configuration options mssql.textlimit and mssql.textsize.
 [2007-10-19 21:59 UTC] alan dot trick at twu dot ca
Why would that have anything do do with anything? Aren't those just limits on the maximum amount of text that can come through?

My values in php.ini are:

mssql.textlimit = 20971520
mssql.textsize = 20971520

I had to set it because mssql was cropping some of my long text fields.
 [2007-10-21 15:30 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

See comments for previous bugs on this issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC