日期:2012-12-19  浏览次数:20535 次

 

<?php // -*- C++ -*-
/*
* $Id: db-oci8.phl,v 1.2 1998/10/01
19:16:06 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(<