封装了ORACLE函数的数据库操作类
php // -*- C++ -*-
/*
* $Id: db-oci8.phl,v 1.2 1998/10/01 ssb Exp $
*/
$db_error_code = 0;
$db_error_msg = false;
$db_error_source = false;
/*
* Database specific notes:
*
* - You must configure Oracle listener to use this abstraction layer.
*
*/
/**
* @function db_connect
* @purpose Connect to a database
* @desc
* Connects to a database and returns and identifier for the connection.
* @arg database
* Data source name or database host to connect to.
* @arg user
* Name of user to connect as.
* @arg password
* The user's password.
*/
function db_connect($database, $user, $password)
{
$ret = @OCILogon($user, $password, $database);
db_check_errors($php_errormsg);
return $ret;
}
/*
* Function: db_query
* Arguments: $conn (int) - connection identifier
* $query (string) - SQL statement to execute
* Description: executes an SQL statement
* Returns: false - query failed
* integer - query succeeded, value is result handle
*/
function db_query($conn, $query)
{
$stmt = @OCIParse($conn, $query);
db_check_errors($php_errormsg);
if (!$stmt) {
return false;
}
if (@OCIExecute($stmt)) {
return $stmt;
}
db_check_errors($php_errormsg);
@OCIFreeStatement($stmt);
return false;
}
/*
* Function: db_fetch_row
* Arguments: $stmt (int) - result identifier
* Description: Returns an array containing data from a fetched row.
* Returns: false - error
* (array) - returned row, first column at index 0
*/
function db_fetch_row($stmt)
{
$cols = @OCIFetchInto($stmt, &$row);
if (!$cols) {
db_check_errors($php_errormsg);
return false;
}
return $row;
}
/*
* Function: db_free_result
* Arguments: $stmt (int) - result identifier
* Description: Frees all memory associated with a result identifier.
* Returns: false - failure
* true - success
*/
function db_free_result($stmt)
{
global $db_oci8_pieces;
if (isset($db_oci8_pieces[$stmt])) {
unset($db_oci8_pieces[$stmt]);
}
$ret = @OCIFreeStatement($stmt);
db_check_errors($php_errormsg);
return $ret;
}
/*
* Function: db_disconnect
* Arguments: $connection (int) - connection identifier
* Description: closes a database connection
* Returns: false - failure
* true - success
*/
function db_disconnect($connection)
{
$ret = @OCILogoff($connection);
db_check_errors($php_errormsg);
return $ret;
}
/*
* Function: db_autocommit
* Arguments: $connection (int) - connection identifier
* Description: turn autocommit on or off
* Returns: false - failure
* true - success
*/
function db_autocommit($connection, $enabled)
{
if (!$enabled) {
db_post_error(0, "Transactions not yet implemented");
return false;
}
return true;
}
function db_commit($connection)
{
return true;
}
function db_rollback($connection)
{
db_post_error(0, "Transactions not yet implemented");
return false;
}
function db_quote_string($string)
{
$ret = ereg_replace( "'", "''", $string);
return $ret;
}
function db_prepare($connection, $query)
{
global $db_oci8_pieces;
$pieces = explode( "?", $query);
$new_query = "";
$last_piece = sizeof($pieces) - 1;
print "br>last_piece=$last_piece\n";
while (list($i, $piece) = each($pieces)) {
$new_query .= $piece;
if ($i last_piece) {
$new_query .= ":var$i";
}
}
print "br>new_query=$new_query\n";
$stmt = @OCIParse($connection, $new_query);
if (!$stmt) {
db_check_errors($php_errormsg);
return false;
}
for ($i = 0; $i last_piece; $i++) {
$bindvar = ":var$i";
print "br>trying to bind $bindvar\n";
if (!@OCIBindByName($stmt, $bindvar, &$db_oci8_pieces[$stmt][$i])) {
db_check_errors($php_errormsg);
@OCIFreeStatement($stmt);
return false;
}
}
return $stmt;
}
function db_execute($stmt, $data)
{
global $db_oci8_pieces;
while (list($i, $value) = each($data)) {
$db_oci8_pieces[$stmt][$i] = $data[$i];
}
$ret = @OCIExecute($stmt);
if (!$ret) {
db_check_errors($php_errormsg);
return false;
}
return true;
}
function db_error_code()
{
global $db_error_code;
return $db_error_code;
}
function db_error_msg()
{
global $db_error_msg;
return $db_error_msg;
}
function db_error_source()
{
global $db_error_source;
return $db_error_source;
}
function db_check_errors($errormsg)
{
global $db_error_code, $db_error_msg, $db_error_source;
if (ereg( '^([^:]*): (...-.....): (.*)', $errormsg, &$data)) {
list($foo, $function, $db_error_code, $db_error_msg) = $data;
$db_error_msg = "$function: $db_error_msg";
$db_error_source = "[Oracle][PHP][OCI8]";
} elseif (ereg( '^([^:]*): (.*)', $errormsg, &$data)) {
list($foo, $function, $db_error_msg) = $data;
$db_error_msg = "$function: $db_error_msg";
$db_error_code = 0;
$db_error_source = "[PHP][OCI8][db-oci8]";
} else {
$db_error_msg = $errormsg;
$db_error_code = 0;
$db_error_source = "[PHP][OCI8][db-oci8]";
}
}
function db_post_error($code, $message)
{
global $db_error_code, $db_error_msg, $db_error_source;
$db_error_code = $code;
$db_error_msg = $message;
$db_error_source = "[PHP][OCI8][db-oci8]";
}
function db_api_version()
{
return 10; // 1.0
}
?>

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

PHP作为一种流行的Web开发语言,已经被使用了很长时间。PHP中集成的PDO(PHP数据对象)类是我们在开发Web应用程序过程中与数据库进行交互的一种常用方法。但是,一些PHP开发者经常遇到的问题是,当使用PDO类与数据库进行交互时,他们会收到这样的错误:PHPFatalerror:CalltoundefinedmethodPDO::prep

在Vue应用中使用axios是十分常见的,axios是一种基于Promise的HTTP客户端,可以用于浏览器和Node.js。在开发过程中,有时会出现“Uncaught(inpromise)Error:Requestfailedwithstatuscode500”的错误提示,对于开发者来说,这个错误提示可能有些难以理解和解决。本文将会探讨这

Oracle和DB2是两个知名的关系型数据库管理系统(RDBMS),在企业级应用中被广泛使用。在本文中,我们将对Oracle和DB2这两种数据库技术进行比较并进行详细解析,包括其特点、性能、功能和使用示例等方面的分析。一、Oracle数据库技术概述Oracle是由美国甲骨文公司开发的一种关系型数据库管理系统。它被广泛应用于企业级应用中,具有强大的性能、稳定性

Oracle和DB2是两个常用的关系型数据库管理系统,它们都有自己独特的SQL语法和特点。本文将针对Oracle和DB2的SQL语法进行比较与区别,并提供具体的代码示例。数据库连接在Oracle中,使用以下语句连接数据库:CONNECTusername/password@database而在DB2中,连接数据库的语句如下:CONNECTTOdataba

解决C++代码中出现的“error:incompletetypeisnotallowed”问题在C++的编程过程中,有时候会遇到一些编译错误,其中一个常见的错误是“error:incompletetypeisnotallowed”。这个错误通常是由于在使用不完整的类型进行操作时引起的。本文将介绍这个错误的原因,并提供几种解决方法。首先,我

“0271:real time clock error”开不开机的解决办法:1、按一下F1,在出现的界面中,将选项栏转到第三项“Date/Time”;2、将系统时间手动修改成现在的时间;3、按F10,在弹出的对话框中,选择yes;4、重新打开笔记本即可正常开机。

解决C++代码中出现的“error:expectedinitializerbefore'datatype'”问题在C++编程中,有时候我们在编写代码时会遇到一些编译错误,其中一种常见的错误是“error:expectedinitializerbefore'datatype'”。这个错误通常在变量声明或函数定义中发生,可能导致程序无法正确编译或

C语言return的用法有:1、对于返回值类型为void的函数,可以使用return语句来提前结束函数的执行;2、对于返回值类型不为void的函数,return语句的作用是将函数的执行结果返回给调用者;3、提前结束函数的执行,在函数内部,我们可以使用return语句来提前结束函数的执行,即使函数并没有返回值。
