oracle资料库函式库return ora_numcols($this->Query_ID); } 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]; } /* public: sequence number */ function nextid($seq_name) { $this->connect(); /* Independent Query_ID */ $Query_ID = ora_open($this->Link_ID); if(!@ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL")) { // There is no such sequence yet, then create it if(!@ora_parse($Query_ID,"CREATE SEQUENCE $seq_name") || !@ora_exec($Query_ID) ) { $this->halt("<BR> nextid() function - unable to create sequence"); return 0; } @ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL"); } if (!@ora_exec($Query_ID)) { $this->halt("<BR>ora_exec() failed:<BR>nextID function"); } if (@ora_fetch($Query_ID) ) { $next_id = ora_getcolumn($Query_ID, 0); } else { $next_id = 0; } if ( $Query_ID > 0 ) { ora_close($Query_ID); } return $next_id; } function disconnect() { if($this->Debug) { echo "Debug: Disconnecting $this->Query_ID...<br>n"; } if ( $this->Query_ID < 1 ) { echo "<B>Warning</B>: disconnect(): Cannot free ID $this->Query_IDn"; # return(); } ora_close($this->Query_ID); $this->Query_ID=0; } /* private: error handling */ function halt($msg) { if ($this->Halt_On_Error == "no") return; $this->haltmsg($msg); if ($this->Halt_On_Error != "report") die("Session halted."); } function haltmsg($msg) { printf("</td></tr></table><br><b>Database error:</b> %s<br>n", $msg); printf("<b>Oracle Error</b>: %s (%s)<br>n", $this->Errno, $this->Error); } 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; } // Some transaction support // Methods are used in ct_oracle.inc function begin_transaction() { $this->connect(); // Now, disable autocommit Ora_CommitOff($this->Link_ID); if ($this->Debug) { print "BEGIN TRANSACTION<BR>"; } } function end_transaction() { if ($this->Debug) { print "BEGIN TRANSACTION<BR>"; } $res = 1; if(!@Ora_Commit($this->Link_ID)) { Ora_CommitOn($this->Link_ID); $this->halt("Unable to finish transaction"); $res = 0; } // Enable autocommit again Ora_CommitOn($this->Link_ID); if ($this->Debug) { print "END TRANSACTION : $res<BR>"; } return $res; } } ?> 上一篇:一个用于网络的工具函数库 下一篇:PHP聊天室技术 更多相关文章
|
推荐文章
精彩文章
|