阅读内容 

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

[日期:2005-04-10] 来源:中国站长学院  作者:郁郁小蝎 [字体: ]
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数据库插入数据的示例程序:



向<a href="http://www.blue1000.com/bkhtml/c94/" title="ORACLE教程">Oracle</a><a href="http://www.blue1000.com/bkhtml/c86" title="数据库教程">数据库</a>中插入数据

































ID name Description
  





//先设置两个环境变量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);

}

?>




阅读:
录入:

推荐 】 【 打印
相关新闻      
本文评论       全部评论
发表评论
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款


点评: 字数
姓名:
Advertisement
内容查询


Advertisement