如何使用 PHP 从 Oracle 数据库中选择数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5959053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:02:31 来源:igfitidea点击:
How to SELECT data from Oracle database using PHP
提问by Tharindu
How do I fetch the EMPNO
and ENAME
columns from the table called emp
?
如何从名为 的表中获取EMPNO
和ENAME
列emp
?
This is my connection string:
这是我的连接字符串:
if ($c = oci_connect("tharindu", "123456", "localhost/XE")) {
echo "Successfully connected to Oracle.";
oci_close($c);
} else {
$err = oci_error();
echo "Oracle Connect Error " . $err['text'];
}
回答by Rasel
$array = oci_parse($c, "SELECT EMPNO,ENAME
FROM emp");
oci_execute($array);
while($row=oci_fetch_array($array))
{
echo $row[0]." ".$row[1];
}