phpBB

Code Changes

File: includes/db/mssql_odbc.php

  Unmodified   Added   Modified   Removed
Line 32Line 32
class dbal_mssql_odbc extends dbal
{
var $last_query_text = '';

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

 
	var $connect_error = '';


/**
* Connect to server


/**
* Connect to server

Line 40Line 41
	{
$this->persistency = $persistency;
$this->user = $sqluser;

	{
$this->persistency = $persistency;
$this->user = $sqluser;

		$this->server = $sqlserver . (($port) ? ':' . $port : '');

 
		$this->dbname = $database;

		$this->dbname = $database;

 

$port_delimiter = (defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN') ? ',' : ':';
$this->server = $sqlserver . (($port) ? $port_delimiter . $port : '');


$max_size = @ini_get('odbc.defaultlrl');
if (!empty($max_size))


$max_size = @ini_get('odbc.defaultlrl');
if (!empty($max_size))

Line 66Line 69
			@ini_set('odbc.defaultlrl', $max_size);
}


			@ini_set('odbc.defaultlrl', $max_size);
}


		$this->db_connect_id = ($this->persistency) ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword);


















		if ($this->persistency)
{
if (!function_exists('odbc_pconnect'))
{
$this->connect_error = 'odbc_pconnect function does not exist, is odbc extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @odbc_pconnect($this->server, $this->user, $sqlpassword);
}
else
{
if (!function_exists('odbc_connect'))
{
$this->connect_error = 'odbc_connect function does not exist, is odbc extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @odbc_connect($this->server, $this->user, $sqlpassword);
}


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

/**
* Version information about used database


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

/**
* Version information about used database

 
	* @param bool $raw if true, only return the fetched sql_server_version
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
* @return string sql server version

	*/

	*/

	function sql_server_info()





	function sql_server_info($raw = false, $use_cache = true)
{
global $cache;

if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false)

	{
$result_id = @odbc_exec($this->db_connect_id, "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')");


	{
$result_id = @odbc_exec($this->db_connect_id, "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')");


Line 85Line 112
			@odbc_free_result($result_id);
}


			@odbc_free_result($result_id);
}


		if ($row)









			$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;

if (!empty($cache) && $use_cache)
{
$cache->put('mssqlodbc_version', $this->sql_server_version);
}
}

if ($raw)

		{

		{

			return 'MSSQL (ODBC)<br />' . implode(' ', $row);

			return $this->sql_server_version;

		}


		}


		return 'MSSQL (ODBC)';

		return ($this->sql_server_version) ? 'MSSQL (ODBC)<br />' . $this->sql_server_version : 'MSSQL (ODBC)';

	}

/**

	}

/**

Line 174Line 209
			return false;
}


			return false;
}


		return ($this->query_result) ? $this->query_result : false;

		return $this->query_result;

	}

/**

	}

/**

Line 236Line 271
		}

return ($query_id !== false) ? @odbc_fetch_array($query_id) : false;

		}

return ($query_id !== false) ? @odbc_fetch_array($query_id) : false;

	}

/**
* Seek to given row number
* rownum is zero-based
*/
function sql_rowseek($rownum, &$query_id)
{
global $cache;

if ($query_id === false)
{
$query_id = $this->query_result;
}

if (isset($cache->sql_rowset[$query_id]))
{
return $cache->sql_rowseek($rownum, $query_id);
}

if ($query_id === false)
{
return false;
}

$this->sql_freeresult($query_id);
$query_id = $this->sql_query($this->last_query_text);

if ($query_id === false)
{
return false;
}

// We do not fetch the row for rownum == 0 because then the next resultset would be the second row
for ($i = 0; $i < $rownum; $i++)
{
if (!$this->sql_fetchrow($query_id))
{
return false;
}
}

return true;

 
	}

/**

	}

/**

Line 333Line 325
	*/
function sql_escape($msg)
{

	*/
function sql_escape($msg)
{

		return str_replace("'", "''", $msg);









		return str_replace(array("'", "\0"), array("''", ''), $msg);
}

/**
* {@inheritDoc}
*/
function sql_lower_text($column_name)
{
return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))";

	}

/**

	}

/**

Line 360Line 360
	*/
function _sql_error()
{

	*/
function _sql_error()
{

		return array(



		if (function_exists('odbc_errormsg'))
{
$error = array(

			'message'	=> @odbc_errormsg(),

			'message'	=> @odbc_errormsg(),

			'code'		=> @odbc_error()

				'code'		=> @odbc_error(),

		);

		);

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

return $error;

	}

/**

	}

/**