phpBB

Code Changes

File: includes/db/oracle.php

  Unmodified   Added   Modified   Removed
Line 25Line 25
class dbal_oracle extends dbal
{
var $last_query_text = '';

class dbal_oracle extends dbal
{
var $last_query_text = '';

 
	var $connect_error = '';


/**
* Connect to server


/**
* Connect to server

Line 48Line 49
			$connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database;
}


			$connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database;
}


		$this->db_connect_id = ($new_link) ? @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8') : (($this->persistency) ? @ociplogon($this->user, $sqlpassword, $connect, 'UTF8') : @ocilogon($this->user, $sqlpassword, $connect, 'UTF8'));



























		if ($new_link)
{
if (!function_exists('ocinlogon'))
{
$this->connect_error = 'ocinlogon function does not exist, is oci extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8');
}
else if ($this->persistency)
{
if (!function_exists('ociplogon'))
{
$this->connect_error = 'ociplogon function does not exist, is oci extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @ociplogon($this->user, $sqlpassword, $connect, 'UTF8');
}
else
{
if (!function_exists('ocilogon'))
{
$this->connect_error = 'ocilogon function does not exist, is oci extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8');
}


return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
}


return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
}

Line 56Line 83
	/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version

	/**
* Version information about used database
* @param bool $raw if true, only return the fetched sql_server_version

 
	* @param bool $use_cache forced to false for Oracle

	* @return string sql server version
*/

	* @return string sql server version
*/

	function sql_server_info($raw = false)

	function sql_server_info($raw = false, $use_cache = true)

	{

	{

 
		/**
* force $use_cache false. I didn't research why the caching code below is commented out
* but I assume its because the Oracle extension provides a direct method to access it
* without a query.
*/

$use_cache = false;

/*
global $cache;


/*
global $cache;


Line 136Line 171
	*/
function _rewrite_where($where_clause)
{

	*/
function _rewrite_where($where_clause)
{

		preg_match_all('/\s*(AND|OR)?\s*([\w_.]++)\s*(?:(=|<[=>]?|>=?)\s*((?>\'(?>[^\']++|\'\')*+\'|[\d-.]+))|((NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))/', $where_clause, $result, PREG_SET_ORDER);

		preg_match_all('/\s*(AND|OR)?\s*([\w_.()]++)\s*(?:(=|<[=>]?|>=?|LIKE)\s*((?>\'(?>[^\']++|\'\')*+\'|[\d-.()]+))|((NOT )?IN\s*\((?>\'(?>[^\']++|\'\')*+\',? ?|[\d-.]+,? ?)*+\)))/', $where_clause, $result, PREG_SET_ORDER);

		$out = '';
foreach ($result as $val)
{

		$out = '';
foreach ($result as $val)
{

Line 255Line 290
				// We overcome Oracle's 4000 char limit by binding vars
if (strlen($query) > 4000)
{

				// We overcome Oracle's 4000 char limit by binding vars
if (strlen($query) > 4000)
{

					if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/s', $query, $regs))

					if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/sU', $query, $regs))

					{
if (strlen($regs[3]) > 4000)
{
$cols = explode(', ', $regs[2]);

					{
if (strlen($regs[3]) > 4000)
{
$cols = explode(', ', $regs[2]);

 


							preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER);

							preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER);

 

/* The code inside this comment block breaks clob handling, but does allow the
database restore script to work. If you want to allow no posts longer than 4KB
and/or need the db restore script, uncomment this.


if (sizeof($cols) !== sizeof($vals))
{
// Try to replace some common data we know is from our restore script or from other sources
$regs[3] = str_replace("'||chr(47)||'", '/', $regs[3]);
$_vals = explode(', ', $regs[3]);

$vals = array();
$is_in_val = false;
$i = 0;
$string = '';

foreach ($_vals as $value)
{
if (strpos($value, "'") === false && !$is_in_val)
{
$vals[$i++] = $value;
continue;
}

if (substr($value, -1) === "'")
{
$vals[$i] = $string . (($is_in_val) ? ', ' : '') . $value;
$string = '';
$is_in_val = false;

if ($vals[$i][0] !== "'")
{
$vals[$i] = "''" . $vals[$i];
}
$i++;
continue;
}
else
{
$string .= (($is_in_val) ? ', ' : '') . $value;
$is_in_val = true;
}
}

if ($string)
{
// New value if cols != value
$vals[(sizeof($cols) !== sizeof($vals)) ? $i : $i - 1] .= $string;
}

$vals = array(0 => $vals);
}
*/


$inserts = $vals[0];
unset($vals);


$inserts = $vals[0];
unset($vals);

Line 566Line 656
	function _sql_custom_build($stage, $data)
{
return $data;

	function _sql_custom_build($stage, $data)
{
return $data;

 
	}

function _sql_bit_and($column_name, $bit, $compare = '')
{
return 'BITAND(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : '');
}

function _sql_bit_or($column_name, $bit, $compare = '')
{
return 'BITOR(' . $column_name . ', ' . (1 << $bit) . ')' . (($compare) ? ' ' . $compare : '');

	}

/**

	}

/**

Line 573Line 673
	* @access private
*/
function _sql_error()

	* @access private
*/
function _sql_error()

 
	{
if (function_exists('ocierror'))

	{
$error = @ocierror();
$error = (!$error) ? @ocierror($this->query_result) : $error;

	{
$error = @ocierror();
$error = (!$error) ? @ocierror($this->query_result) : $error;

Line 585Line 687
		else
{
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();

		else
{
$error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array();

 
			}
}
else
{
$error = array(
'message' => $this->connect_error,
'code' => '',
);

		}

return $error;

		}

return $error;