PHP 4.0 Bug #7569 Updated: Transmuting indices
| From: | waldschrott@php.net | Date: | Thu, 02 Nov 2000 11:39:47 +0000 |
| Subject: | PHP 4.0 Bug #7569 Updated: Transmuting indices | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-36773@lists.php.net to get a copy of this message | ||
ID: 7569
Updated by: waldschrott
Reported By: ignacio@openservices.net
Status: Analyzed
Bug Type: Documentation problem
Assigned To:
Comments:
I can´t verify if mssql functions are wrong, it´s not
installed here, every function decides itself how to convert
or not to convert, but basically these 4 are not equivalent
$row=array(1=>NULL,2=>FALSE,3=>"\0",4=>"");
var_dump($row);
I agree, the docs could need some update on these (eg. NULL)
and boolean types (resource type too)
Previous Comments:
---------------------------------------------------------------------------
[2000-11-01 22:44:44] ignacio@openservices.net
Ah, I see now. What I initially thought was "" is in fact false. It seems that NULLs in
MS-SQL are converted to falses in Sybase-CT under PHP. Lovely.
Well, changing the ""/0 to false in the generation segment fixed the code and explains the
problems. Now all we need is for somebody to document this NULL=>false fact. And some
documentation about the Boolean type might be appreciated as well :)
---------------------------------------------------------------------------
[2000-11-01 19:54:07] waldschrott@php.net
please place this in front of that print_r()
a) var_dump($kind);
b) var_dump($row1);
and append the output here
---------------------------------------------------------------------------
[2000-11-01 13:41:26] ignacio@openservices.net
Changing the code so that 0 is used in place of "" when generating $kind allows the code
to run correctly, but it does not solve the problem.
---------------------------------------------------------------------------
[2000-11-01 12:48:28] ignacio@openservices.net
Well, you see, I can't reproduce it without database code. Here's a smaller version that
emulates the data structures:
"""
<?php
$row1=Array(
0 => "Advertising Space",
"KindNm" => "Advertising Space",
1 => "",
"SubKindNm" => "",
2 => "",
"SubSubKindNm" => "",
3 => 100,
"GrantKindID" => 100
);
$kind=Array(
"Advertising Space" => Array(
"" => Array(
0 => 100,
1 => 160
)
)
);
print("<pre>");
print_r($kind[$row1["KindNm"]][$row1["SubKindNm"]]);
print("</pre>");
?>
"""
The problem: it works perfectly.
Here's the actual trouble code:
"""
<?php
error_reporting(2047);
...
while ($row1=mssql_fetch_array($result1))
{
$val=$row1["GrantKindID"];
if (empty($row1["SubSubKindNm"]))
{
print_r($kind[$row1["KindNm"]][$row1["SubKindNm"]]);
if (isset($kind[$row1["KindNm"]][$row1["SubKindNm"]]))
{
$k=$kind[$row1["KindNm"]][$row1["SubKindNm"]];
$val=$k[0].":".$k[1];
};
};
?>
<option value="<?=$val?>"><?=$val?></option>
<?php
};
?>
"""
$kind is also much larger than the small one given above, but I'm not convinced that that has
anything to do with this problem.
---------------------------------------------------------------------------
[2000-11-01 12:18:29] waldschrott@php.net
Please provide a reduced code fragment (<15 lines) producing
this behaviour.
Put no database queries etc. in it to ensure that we can
reproduce it easily.
---------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view the rest of the comments,
please view the bug report online.
Full Bug description available at: http://bugs.php.net/?id=7569