ID: 12966
Updated by: sniper
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Closed
Old Bug Type: *Database Functions
Bug Type: Documentation problem
Operating System: System HP-UX dev2 B.11.00 A
PHP Version: 4.0.5
New Comment:

You should use the constants: 

INGRES_ASSOC, INGRES_NUM, INGRES_BOTH

Documentation is fixed now. (might not show yet online)

Note: The first parameter given on your first example
is propably 1 as the connection resource number propably
is 1. To get it to use the default value, don't give
any parameters to ingres_fetch_array().


--Jani



Previous Comments:
------------------------------------------------------------------------

[2001-08-27 05:06:47] [EMAIL PROTECTED]

When a ingres_fetch_array is done without FLAG, the result is not ok.

Constantes II_NUM, II_ASSOC et II_BOTH are not known by PHP.
We must use 1,2,3 in the fetch function to avoid this problem.

Example with this small script :

<?php
print "Without FLAG (Suppose to be II_BOTH by défaut)<br>";
$comm = ingres_connect("dtm", "pmm", "pmm01");
ingres_query("select cplan,vlongarti,vhautarti from p301dimec WHERE
cplan='2247620'", $comm);
$result = ingres_fetch_array($comm);
print var_dump($result);
print "<br>";
ingres_close($comm);

$comm = ingres_connect('nart', 'pmm', 'pmm01');
ingres_query("select crefart,nordart,nvlogart from o101comb WHERE
crefart='0000210'", $comm);
$result = ingres_fetch_array($comm);
print var_dump($result);
print "<br><br>";

print "With FLAG = 1 (II_ASSOC)<br>";
$comm = ingres_connect("dtm", "pmm", "pmm01");
ingres_query("select cplan,vlongarti,vhautarti from p301dimec WHERE
cplan='2247620'", $comm);
$result = ingres_fetch_array(1,$comm);
print var_dump($result);
print "<br>";
ingres_close($comm);

$comm = ingres_connect('nart', 'pmm', 'pmm01');
ingres_query("select crefart,nordart,nvlogart from o101comb WHERE
crefart='0000210'", $comm);
$result = ingres_fetch_array(1,$comm);
print var_dump($result);
print "<br><br>";

print "With FLAG = 2 (II_NUM)<br>";
$comm = ingres_connect("dtm", "pmm", "pmm01");
ingres_query("select cplan,vlongarti,vhautarti from p301dimec WHERE
cplan='2247620'", $comm);
$result = ingres_fetch_array(2,$comm);
print var_dump($result);
print "<br>";
ingres_close($comm);

$comm = ingres_connect('nart', 'pmm', 'pmm01');
ingres_query("select crefart,nordart,nvlogart from o101comb WHERE
crefart='0000210'", $comm);
$result = ingres_fetch_array(2,$comm);
print var_dump($result);
print "<br><br>";

print "With FLAG = 3 (II_BOTH)<br>";
$comm = ingres_connect("dtm", "pmm", "pmm01");
ingres_query("select cplan,vlongarti,vhautarti from p301dimec WHERE
cplan='2247620'", $comm);
$result = ingres_fetch_array(3,$comm);
print var_dump($result);
print "<br>";
ingres_close($comm);

$comm = ingres_connect('nart', 'pmm', 'pmm01');
ingres_query("select crefart,nordart,nvlogart from o101comb WHERE
crefart='0000210'", $comm);
$result = ingres_fetch_array(3,$comm);
print var_dump($result);
print "<br><br>";

?>

Results are :

Without FLAG (Suppose to be II_BOTH by défaut)
array(3) { ["cplan"]=> string(7) "2247620" ["vlongarti"]=> float(0)
["vhautarti"]=> float(145) } 
array(3) { [1]=> string(7) "0000210" [2]=> string(5) "00002" [3]=>
string(1) "1" } 

As you can see above, first array is only associative and second is only numeric.
See the other case :

With FLAG = 1 (II_ASSOC)
array(3) { ["cplan"]=> string(7) "2247620" ["vlongarti"]=> float(0)
["vhautarti"]=> float(145) } 
array(3) { ["crefart"]=> string(7) "0000210" ["nordart"]=> string(5)
"00002" ["nvlogart"]=> string(1) "1" } 

With FLAG = 2 (II_NUM)
array(3) { [1]=> string(7) "2247620" [2]=> float(0) [3]=> float(145) } 
array(3) { [1]=> string(7) "0000210" [2]=> string(5) "00002" [3]=>
string(1) "1" } 

With FLAG = 3 (II_BOTH)
array(6) { [1]=> string(7) "2247620" ["cplan"]=> string(7) "2247620" [2]=>
float(0) ["vlongarti"]=> float(0) [3]=> float(145) ["vhautarti"]=>
float(145) } 
array(6) { [1]=> string(7) "0000210" ["crefart"]=> string(7) "0000210"
[2]=> string(5) "00002" ["nordart"]=> string(5) "00002" [3]=> string(1) "1"
["nvlogart"]=> string(1) "1" } 

Thanks...



------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=12966&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to