PHP调用三种数据库的方法(3)


Posted in PHP onOctober 09, 2006

Oracle(甲骨文)是世界上最为流行的关系数据库。它是大公司推崇的工业化的强有力的引擎。我们先看看其相关的函数:

(1)integer ora_logon(string user , string password)

开始对一个Oracle数据库服务器的连接。

(2)integer ora_open(integer connection)

打开给出的连接的游标。

(3)integer ora_do(integer connection, string query)

在给出的连接上执行查询。PHP生成一个指示器,解析查询,并执行之。

(4)integer ora_parse(integer cursor, string query)

解析一个查询并准备好执行。

(5)boolean ora_exec(integer cursor)

执行一个先前由ora_parse函数解析过的查询。

(6)boolean ora_fetch(integer cursor)

此函数会使得一个执行过的查询中的行被取到指示器中。这使得您可以调用ora_getcolumn函数。

(7)string ora_getcolumn(integer cursor, integer column)

返回当前的值。列由零开始的数字索引。

(8)boolean ora_logoff(integer connection)

断开对数据库服务器的链接。

以下是向ORACLE数据库插入数据的示例程序:

<html>

<head><title>向ORACLE数据库中插入数据</title></head>

<body>

<form action="<?echo $PHP_SELF;?>" method="post">

<table border="1" cellspacing="0" cellpadding="0">

<tr>

<th>ID</th>

<th>name</th>

<th>Description</th>

</tr>

<tr>

<td><input type="text" name="name" maxlength="50" size="10"></td>

<td><input type="text" name="email" maxlength="255" size="30"></td>

<td><input type="text" name="Description" maxlength="255" size="50"></td>

</tr>

<tr align="center">

<td colspan="3"><input type="submit" value="提交">  <input type="reset" value="重写"></td>

</tr>

</table>

</form>

<?

//先设置两个环境变量ORACLE_HOME,ORACLE_SID

putenv("ORACLE_HOME=/oracle/app/oracle/product/8.0.4");

putenv("ORACLE_SID=ora8");

//设置网页显示中文

putenv("NLS_LANG=Simplified_Chinese.zhs16cgb231280");

if($connection=ora_logon("scott","tiger")) {

//库表test有ID,name,Description三项

$sql = 'insert into test(ID,name,Description) values ';

$sql .= '('' . $ID . '','' . $name . '',''. $Description . '')';

if($cursor=ora_do($connect,$sql)) {

print("insert finished!");

}

$query = 'select * from test';

if($cursor=ora_do($connect,$query)) {

ora_fetch($cursor);

$content0=ora_getcolumn($cursor,0);

$content1=ora_getcolumn($cursor,1);

$content2=ora_getcolumn($cursor,2);

print("$content0");

print("$content1");

print("$content2");

ora_close($cursor);

}

ora_logoff($connection);

}

?>

</body>

</html>

PHP 相关文章推荐
实用函数3
Nov 08 PHP
fleaphp常用方法分页之Pager使用方法
Apr 23 PHP
使用php实现快钱支付功能(涉及到接口)
Jul 01 PHP
Zend studio文件注释模板设置方法
Sep 29 PHP
php实现图片文件与下载文件防盗链的方法
Nov 03 PHP
php快速查找数据库中恶意代码的方法
Apr 01 PHP
php删除文本文件中重复行的方法
Apr 28 PHP
CodeIgniter与PHP5.6的兼容问题
Jul 16 PHP
使用symfony命令创建项目的方法
Mar 17 PHP
php中foreach结合curl实现多线程的方法分析
Sep 22 PHP
PHP脚本自动识别验证码查询汽车违章
Dec 20 PHP
PHP实现驼峰样式字符串(首字母大写)转换成下划线样式字符串的方法示例
Aug 10 PHP
PHP调用三种数据库的方法(2)
Oct 09 #PHP
PHP调用三种数据库的方法(1)
Oct 09 #PHP
php数据库连接
Oct 09 #PHP
基于文本的访客签到簿
Oct 09 #PHP
基于文本的搜索
Oct 09 #PHP
实现分十页分向前十页向后十页的处理
Oct 09 #PHP
实现“上一页”和“下一页按钮
Oct 09 #PHP
You might like
php打造属于自己的MVC框架
2012/03/07 PHP
PHP创建word文档的方法(平台无关)
2016/03/29 PHP
PHP的openssl加密扩展使用小结(推荐)
2016/07/18 PHP
ThinkPHP+EasyUI之ComboTree中的会计科目树形菜单实现方法
2017/06/09 PHP
Docker 安装 PHP并与Nginx的部署实例讲解
2021/02/27 PHP
css动画效果之animation的常用样式
2021/03/09 HTML / CSS
document.all还是document.getElementsByName?
2006/07/21 Javascript
JavaScript国旗变换效果代码
2008/08/13 Javascript
javascript 清空form表单中某种元素的值
2009/12/26 Javascript
基于jQuery的简单的列表导航菜单
2011/03/02 Javascript
chrome下img加载对height()的影响示例探讨
2014/05/26 Javascript
Javascript调用函数方法的几种方式介绍
2015/03/20 Javascript
使用node+vue.js实现SPA应用
2016/01/28 Javascript
基于jquery插件编写countdown计时器
2016/06/12 Javascript
js获取当前页的URL与window.location.href简单方法
2017/02/13 Javascript
详解node HTTP请求客户端 - Request
2017/05/05 Javascript
关于Bootstrap按钮组件消除黄框的方法
2017/05/19 Javascript
学习Vue组件实例
2018/04/28 Javascript
小程序组件之自定义顶部导航实例
2019/06/12 Javascript
[01:06:32]DOTA2上海特级锦标赛D组资格赛#1 EG VS VP第一局
2016/02/28 DOTA
[00:59]DOTA2英雄背景故事——上古巨神
2020/06/28 DOTA
linux 下实现python多版本安装实践
2014/11/18 Python
TensorFlow的权值更新方法
2018/06/14 Python
对python特殊函数 __call__()的使用详解
2019/07/02 Python
python读文件的步骤
2019/10/08 Python
wxpython布局的实现方法
2019/11/01 Python
matplotlib教程——强大的python作图工具库
2020/10/15 Python
如何利用python读取micaps文件详解
2020/10/18 Python
会走动的图形html5时钟示例
2014/04/27 HTML / CSS
video.js支持m3u8格式直播的实现示例
2020/05/20 HTML / CSS
欧缇丽英国官方网站:Caudalie英国
2016/08/17 全球购物
英格兰足协官方商店:England Store
2019/07/12 全球购物
德国便宜的宠物店:Brekz.de
2020/10/23 全球购物
材料加工硕士生求职信
2013/10/10 职场文书
护士2014年终工作总结
2014/11/11 职场文书
使用python+pygame开发消消乐游戏附完整源码
2021/06/10 Python