Re:Connection to ORACLE
| From: | 陈伟平 | Date: | Wed, 03 Jan 2001 10:58:28 +0000 |
| Subject: | Re:Connection to ORACLE | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-4759@lists.php.net to get a copy of this message | ||
Hi,Jean-Christophe Le Brun:
I have tried for several times to connect ORACLE database the
same as you. Now I found that using OCILogon() is the best choice.
At first,you should install ORACLE CLIENT 8.0.X.X for windows,
(You can download from ORACLE) which is also included in the
ORACLE DATABASE 8.0.X.X for NT. Then, you can use the Net configuration
assitant to create a SID. OK! Now,you can use SID to program as following:
a sample:
<?php
$username=".....";
$password=".....";
$SID=".....";//your SID here
$conn = OCILogon($username,$password,$SID);
$stmt = OCIParse($conn,"select empno, ename from emp");
OCIDefineByName($stmt,"EMPNO",&$empno);
OCIDefineByName($stmt,"ENAME",&$ename);
OCIExecute($stmt);
while (OCIFetch($stmt)) {
echo "empno:".$empno."\n";
echo "ename:".$ename."\n";
}
OCIFreeStatement($stmt);
OCILogoff($conn);
?>
quite easy!Try it!You can get error number from browser.
Sincerely,
Weiping Tsen
cwp@chimeb.edu.cn