php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #12966 Problems PHP/INGRES
Submitted: 2001-08-27 05:06 UTC Modified: 2001-08-27 07:38 UTC
From: thierry dot pinon at fr dot alcove dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.5 OS: System HP-UX dev2 B.11.00 A
Private report: No CVE-ID: None
 [2001-08-27 05:06 UTC] thierry dot pinon at fr dot alcove dot com
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...


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-27 07:38 UTC] sniper@php.net
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


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 00:01:30 2024 UTC