php连oracle的类文件[2]

[入库:2005年8月28日] [更新:2007年3月24日]

本文简介:

   " 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;
   }
  
  
   function record_rows($tablename,$condition) {
   $this->connect();
   $this->query("select count(*) as countnum from $tablename where ".$condition);
   if ($this->next_record())
   return ($this->record["countnum"]);
   else
   return 0;
   }
  
   function num_fields() {
   return ocinumcols($this->parse);
   }
  
   function nf() {
   return $this->num_rows();
   }
  
   function np() {
   print $this->num_rows();
   }
  
   function f($name) {
   return $this->record[$name];
   }
  
   function p($name) {
   print $this->record[$name];
   }
  
   function commit()
   {
   return ocicommit($this->link_id);
   }
  
   function disconnect() {
   if($this->debug) {
   printf("disconnecting...
\n");
   }
   ocilogoff($this->link_id);
   }
  
   function halt($msg) {
   printf("database error: %s
\n", $msg);
   printf("oracle error: %s
\n",
   $this->error["message"]);
   die("session halted.");
   }
  
   function lock($table, $mode = "write") {
   $this->connect();
   if ($mode == "write") {
   $parse=ociparse($this->link_id,"lock table $table in row exclusive mode");
   ociexecute($parse);
   } else {
   $result = 1;
   }
   return $result;
   }
  
   function unlock() {
   return $this->query("commit");
   }
  
   function table_names() {
   $this->connect();
   $this->query("
   select table_name,tablespace_name
   from user_tables");
   $i=0;
   while ($this->next_record())
   {
   $info[$i]["table_name"] =$this->record["table_name"];
   $info[$i]["tablespace_name"]=$this->record["tablespace_name"];
   $i++;
   }
   return $info;
   }
  }
  

 

本文关键:php连oracle的类文件
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top