php 访问oracle

<html>
	<body>
		<?php
			header("Content-Type:text/html;charset=gbk"); 
			$dbconn=OCILogon("dbusername","dbpassword","(DESCRIPTION=(ADDRESS=(PROTOCOL =TCP)(HOST=ip)(PORT = 1521))(CONNECT_DATA =(SERVICE_NAME=servername)))"); 
			if($dbconn!=false) 
			{
				 echo "连接成功";
				 echo "<br>";
				 $stmt=oci_parse($dbconn,"select 1 from dual");
				 oci_execute($stmt,OCI_DEFAULT);
				 $result=oci_fetch_assoc($stmt);
		     print_r($result);
		     echo "<br>";
				 if(OCILogOff($dbconn)==true)     
				 {    
				 	  echo "关闭连接成功!";    
				 }
				 }else
				 {
				  	echo "连接失败"; 
				 } 
				 echo "<br>";

	</body>
</html>

你可能感兴趣的:(php 访问oracle)