动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > 数据库 > Oracle教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
数据库:数据库教程,数据库技巧,Oracle教程,MySQL教程,Sybase教程,Access教程,DB2教程,数据库安全,数据库文摘
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ Oracle教程 ]的信息

本月文章推荐
.Oracle9i中如何监视索引并清除监.
.PL/SQL基本语法要素(组图).
.如何在硬碟建置Linux系统之setup.
.Linux 网管 123 --- 升级 Linux.
.Oracle数据库技术(42).
.数据库链应用实例:将一台机器的.
.linux怎么给一个普通用户reboot权.
.Oracle 分析函数的使用二.
.Windows下Oracle9i数据库文件的自.
.Oracle中的汉字显示.
.用sqlplus只输出数据到文本文件的.
.名字中包含了什么?:改善的表空.
.Oracles XMLDB Study NOTE (2).
.互连环境下实现ORACLE数据库分布.
.用Oracle并行查询发挥多CPU的威力.
.Oracle 9I安装使用笔记.
.Oracle 10G 新特性简介.
.检查SQL语句是否应用了索引.
.甲骨文Sun联手 构建新10年战略伙.
.UNIX和WINDOWS2000上的ORACLE的差.

PHP连ORACLE的类文件

发表日期:2008-2-9 |



  putenv("Oracle_SID=oracle8");
  putenv("ORACLE_HOME=/oracle/prodUCt/release/8.1.5");
  
  class db_sql {
  var $Debug = 0;
  var $sqoe = 1; // sqoe= show query on error
  
  var $Database = "dev";
  var $User = "scott";
  var $PassWord = "tiger";
  
  var $Link_ID = 0;
  var $Record = array();
  var $Row;
  var $numRow;
  var $Parse;
  var $Error = "";
  
  function connect() {
  if ( 0 == $this->Link_ID ) {
   if($this->Debug) {
   printf("
Connecting to $this->Database...
\n");
   }
   $this->Link_ID=OCILogon("$this->User","$this->Password");
  
   if (!$this->Link_ID) {
   $this->halt("Link-ID == false " .
   "($this->Link_ID), OCILogon failed");
   }
  
   if($this->Debug) {
   printf("
OBTained the Link_ID: $this->Link_ID
\n");
   }
   }
   }
  
   function query($Query_String) {
   if($Query_String=="")
   {
   echo "执行语句不能为空!";
   return false;
   }
   $this->connect();
  
   $this->Parse=OCIParse($this->Link_ID,$Query_String);
  
   if(!$this->Parse) {
   $this->Error=OCIError($this->Parse);
   } else { OCIExecute($this->Parse);
   $this->Error=OCIError($this->Parse);
   }
  
   $this->Row=0;
  
   if($this->Debug) {
   printf("Debug: query = %s
\n", $Query_String);
   }
  
   if ($this->Error["code"]!=1403 && $this->Error["code"]!=0 && $this->sqoe)
   echo "
  ".$this->Error["message"]."
  Query :\"$Query_String\"";
   $numRow=OCIRowCount($this->Parse);
   return $this->Parse;
  
   }
  
   function next_record() {
   if(0 == OCIFetchInto($this->Parse,$result,OCI_ASSOC+OCI_RETURN_NULLS)) {
   if ($this->Debug) {
   printf("
ID: %d,Rows: %d
\n",
   $this->Link_ID,$this->num_rows());
   }
   $this->Row +=1;
  
   $errno=OCIError($this->Parse);
   if(1403 == $errno) { # 1043 means no more records found
   $this->Error="";
   $this->disconnect();
   $stat=0;
   } else {
   $this->Error=OCIError($this->Parse);
   if($this->Debug) {
   printf("
Error: %s",
   $this->Error["message"]);
   }
   $stat=0;
   }
   } else {
   for($ix=1;$ix<=OCINumcols($this->Parse);$ix++) {
   $col=strtoupper(OCIColumnname($this->Parse,$ix));
   $colreturn=strtolower($col);
   $this->Record[ "$colreturn" ] = $result["$col"];
   if($this->Debug) echo"[$col]:".$result["$col"]."
\n";
   }
   $stat=1;
   }
  
   return $stat;
   }
   function record_exist() {
   if(0 == OCIFetchInto($this->Parse,$result)) {
   return 0;
   } else {
   return 1;
   }
  
   return $stat;
   }
  
   function seek($pos) {
   $this->Row=$pos;
   }
  
   function metadata($table,$full=false) {
   $count = 0;
   $id = 0;
   $res = array();
  
   /*
   * Due to compatibility problems with Table we changed the behavior
   * of metadata();
   * depending on $full, metadata returns the following values:
   *
   * - full is false (default):
   * $result[]:
   * [0]["table"] table name
   * [0]["name"] field name
   * [0]["type"] field type
   * [0]["len"] field length
   * [0]["flags"] field flags ("NOT NULL", "INDEX")
   * [0]["format"] precision and scale of number (eg. "10,2") or empty
   * [0]["index"] name of index (if has one)
   * [0]["chars"] number of chars (if any char-type)
   *
   * - full is true
   * $result[]:
   * ["num_fields"] number of metadata records
   * [0]["table"] table name
   * [0]["name"] field name
   * [0]["type"] field type
   * [0]["len"] field length
   * [0]["flags"] field flags ("NOT NULL", "INDEX")
   * [0]["format"] precision and scale of number (eg. "10,2") or empty
   * [0]["index"] name of index (if has one)
   * [0]["chars"] number of chars (if any char-type)
   * ["meta"][field name] index of field named "field name"
   * The last one is used, if you have a field name, but no index.
   * Test: if (isset($result['meta']['myfield'])) {} ...
   */
  
   $this->connect();
  
   ## This is a RIGHT OUTER JOIN: "(+)", if you want to see, what
   ## this query results try the following:
   ## $table = new Table; $db = new my_DB_Sql; # you have to make
   ## # your own class
   ## $table->show_results($db->query(see query vvvvvv))
   ##
   $this->query("SELECT T.table_name,T.column_name,T.data_type,".
   "T.data_length,T.data_precision,T.data_scale,T.nullable,".
   "T.char_col_decl_length,I.index_name".
   " FROM ALL_TAB_COLUMNS T,ALL_IND_COLUMNS I".
   " WHERE T.column_name=I.column_name (+)".
   " AND T.table_name=I.table_name (+)".
   " AND T.table_name=UPPER('$table') ORDER BY T.column_id");
  
   $i=0;
   while ($this->next_record()) {
   $res[$i]["table"] = $this->Record[table_name];
   $res[$i]["name"] = strtolower($this->Record[column_name]);
   $res[$i]["type"] = $this->Record[data_type];
   $res[$i]["len"] = $this->Record[data_length];
   if ($this->Record[index_name]) $res[$i]["flags"] = "INDEX ";
   $res[$i]["flags"] .= ( $this->Record[nullable] == 'N') ?
'' : 'NOT NULL';
   $res[$i]["format"]= (int)$this->Record[data_precision].",".
   (int)$this->Record[data_scale];
   if ("0,0"==$res[$i]["format"]) $res[$i]["format"]='';
   $res[$i]["index"] = $this->Record[index_name];
   $res[$i]["chars"] = $this->Record[char_col_decl_length];
   if ($full) {
   $j=$res[$i]["name"];
   $res["meta"][$j] = $i;
   $res["meta"][strtoupper($j)] = $i;
   }
   if ($full) $res["meta"][$res[$i]["name"]] = $i;
   $i++;
   }
   if ($full) $res["num_fields"]=$i;
  # $this->disconnect();
   return $res;
   }
  
  
   function affected_rows() {
   return OCIRowCount($this->Parse);
   }
  
   function num_rows() {
   $iii=0;
   while ($this->next_record()) {
   $iii++;
   }
   OCIExecute($this->Parse);
   return $iii
上一篇:[范例]对象库的使用 人气:407
下一篇:关于临时表(from metalink) 人气:501
浏览全部Oracle教程的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-10-7 Web Wiz Forums(论坛系统) v9.53
2008-10-7 Web Wiz Forums(论坛系统) v9.53
2008-10-7 Web Wiz Forums(论坛系统) v9.53
2008-10-7 HDWiki v4.0.1 bulid 081007 UTF
2008-10-7 迅易评选投票管理系统 v10.0
2008-10-7 HDWiki v4.0.1 bulid 081007 GBK
2008-10-7 Bitrac单用户博客 v1.14 bulid 0
2008-10-7 OpenX(广告管理系统) v2.6.2 多国
2008-10-7 乐铺网店系统免费普及版 v3.41
2008-9-29 酷狗音乐(原KuGoo)2008 v5.310 正
2008-9-29 QQTab 1.1
2008-9-29 网络传送带 Net Transport 2.64a
2008-9-29 谷歌金山词霸v1.8
2008-9-29 TweakVI 1.0 Build 1090
2008-9-29 ACDSee Pro 2.5 Build 333 汉化绿
2008-9-29 Winamp v5.541(2189) 周明波简体
2008-9-27 CCleaner 2.12.651
2008-9-27 Mozilla Thunderbird 2.0.0.17 英
  发表评论
姓 名: 验证码:
内 容:
站长工具:网站收录查询 | Google PR查询 | ALEXA排名查询 | CSS在线编辑器 | 广告代码 | js/vbs加密 | md5加密 | 进制转换 | UTF-8 转换工具 | Html转换js | Html转换asp | Html转换php | Html转换perl
实用工具:汉字翻译拼音 | 拼音字典 | 符号对照表 | 个税计算 | 实时汇率查询换算 | 经典小工具 | 汉字简繁转换 | 普通单位换算 | 公制单位换算 | 生辰老黄历 | 国内电话区号 | 国家代码与域名缩写 | 文字加密解密 | 健康查询 | 万年历 | 汉字横竖排版 | 手机号码查询 | 计算器 | ip搜索
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報
防水工事·改修工事 フットサル大会 探偵
SEO対策 中国語教室 ホームページ作成