网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > 代码交流
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

代码交流 ASP,PHP,JSP等网站源代码下载与交流。

Reply
 
Thread Tools Display Modes
  #1   IP: 218.2.29.60
Old 2006-12-15, 07:23 PM
smiling smiling is offline
高级会员
 
Join Date: 2006-02-12
Posts: 502
smiling 正向着好的方向发展
Default 不使用OCI8接口如何连接PHP和Oracle

随着网站规模的扩大,MySql显然不能满足需求,在许多网站都
采用大型数据库Oracle的情况下,如何使用PHP来访问Oracle变的越发重要了。
我从我编写的一个简单iERP系统谈我自己是如何做的,在PHP官方手册里也有说明。
一般情况下或者说大多数人都是用Oracle8 Call-Interface(OCI8)来连接数据库,
我这里介绍不使用OCI8接口而直接使用PHP的Oracle函数来连接数据库并处理数据。

注意:
php.ini配置中要去掉 ;extension=php_oracle.dll 前的分号即
extension=php_oracle.dll

1,连接数据库

使用ora_logon()或者ora_plogon()来连接上数据库
ora_plogon功能与ora_logon类似,只不过ora_plogon开启与 Oracle 的长期连结
直至web服务停止

$handle = ora_plogon(system@localhost, manager) or die;
system@localhost 其中localhost是oracle SID 名称,system是用户名称,manager是用户密码

2,打开游标
$cursor = ora_open($handle);

3,分析语法并执行指令
$query = select count(*) from area where areacode = $addcode;
ora_parse($cursor, $query) or die;
ora_exec($cursor);

4,获取数据
if(ora_fetch($cursor))
$datacount = ora_getcolumn($cursor, 0);
5,关闭游标
ora_close($cursor);

当然了你有可能执行的是delete或者insert语句不存在获取数据的步骤如:
INSERT:(插入)

$handle = ora_plogon(system@localhost, manager) or die;
ora_commiton($handle);
$cursor = ora_open($handle);
$query = insert into area(areacode,areaname) values($addcode,$addname);
ora_parse($cursor, $query) or die;
ora_exec($cursor);
ora_close($cursor);

DELETE:(删除)

$handle = ora_plogon(system@localhost, manager) or die;
$cursor = ora_open($handle);
ora_commiton($handle);
$query = delete from area where areacode in (222,444) ;
ora_parse($cursor, $query) or die;
ora_exec($cursor);
ora_close($cursor);


转自: http://edu.chinaz.com
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 12:29 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.