仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1482|回复: 19
打印 上一主题 下一主题

[学习教程] PHP网页设计PHP挪用三种数据库的办法(3)

[复制链接]
蒙在股里 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-4 00:15:26 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
刚开始因为习惯于ASP格式的写法,总是在这些方面出现问题,自己还总是找不到问题所在,这就提醒了自己,在写代码的时候一定要认真,不能粗心地老是少个“;”或者字母大小写不分,要不然很可能找半天都找不到错误。数据|数据库   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>

  在一个团队之中或者说是在一个公司的工作岗位上,需要注重团队之间的交流合作;在学习或工作上都要端正自己的态度,要以认真的态度来对每件事,这样才能让自己更快的投入、更快的学习,而不至于浪费自己的时间。
蒙在股里 该用户已被删除
沙发
 楼主| 发表于 2015-4-14 04:49:43 | 显示全部楼层
其实没啥难的,多练习,练习写程序,真正的实践比看100遍都有用。不过要熟悉引擎
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-20 12:25

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表