php连接oracle数据库
php连接访问Oracle是用过oci函数,以下是整理的文档
1.安装Apache和php包
yum install -y httpd php*
2.下载Oracle组件
oracle-instantclient-basic-10.2.0.4-1.i386.rpm
oracle-instantclient-sqlplus-10.2.0.4-1.i386.rpm
oracle-instantclient-devel-10.2.0.4-1.i386.rpm
oracle-instantclient-odbc-10.2.0.4-1.i386.rpm
#rpm -ivh oracle-instantclient*(四个组件全部安装上)
此时会生成/usr/lib/oracle/10.2.0.4/client/lib/目录
3.修改/etc/ld.so.conf文件
#vim /etc/ld.so.conf
追加以下内容
/usr/lib/oracle/10.2.0.4/client/lib/
#ldconfig(执行命令)
4.下载OCI8组件
#tar zxvf oci8-1.4.1.tgz
5.编辑OCI8模块
#cd oci8-1.4.1
#phpize(执行命令)
#./configure --with-oci8=instantclient,/usr/lib/oracle/10.2.0.4/client/lib/
#make install
成功后系统会提示你:oci8.so已经成功放入/usr/lib/php/modules/目录中
6.修改php.ini文件
#vim /etc/php.ini
追加以下内容
extension=oci8.so
7.重启Apache服务
service httpd restart
8.使用phpinfo()函数查看
9.编辑php代码连接测试oracle数据库
$conn = oci_connect('scott', 'oracle', '192.168.12.133/orcl');
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
$query = 'select ename,sal from scott.emp';
$stid = oci_parse($conn, $query);
if (!$stid) {
$e = oci_error($conn);
print htmlentities($e['message']);
exit;
}
$r = oci_execute($stid, OCI_DEFAULT);
if(!$r) {
$e = oci_error($stid);
echo htmlentities($e['message']);
exit;
}
print '
'.($item?htmlentities($item):' ').' | ';
oci_close($conn);
?>
最后通过浏览器浏览页面
本文出自 “不积跬步无以至千里” 博客,谢绝转载!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version