OracleXE:PHP連結Oracle XE 簡單語句
阿新 • • 發佈:2019-07-01
<?php
//本PHP小程式連結到本機oracle XE 伺服器上,使用PDO_OCI連結到OracleXE
$tns = "
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = XE)
)
)";
$db_username = "hr";
$db_password = "aking710202";
try{
$conn = new PDO("oci:dbname=".$tns,$db_username,$db_password);
$sth = $conn->prepare('select * from person');
$sth->execute();
$result = $sth->fetchAll(PDO::FETCH_ASSOC);
echo '<pre>';
var_dump($result);
echo '</pre>';
}catch(PDOException $e){
echo ($e->getMessage())