时间:2021-07-01 10:21:17 帮助过:13人阅读
注意:
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://www.bkjia.com/PHPjc/532517.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532517.htmlTechArticle随着网站规模的扩大,MySql显然不能满足需求,在许多网站都 采用大型数据库Oracle的情况下,如何使用PHP来访问Oracle变的越发重要了。 我从...