mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 14:30:32 +02:00
so.... what does this thing do?
well, the super fast, ultra efficient, massively huge BBCode handling system was implemented differently on each DBMS. Although this provided the best performance, the solution was a bit hacky. So what does this new thing do? We use base64 encoding to make everything nice and shiny, it turns into nice, safe characters that we can just jam into varchars on essentially any database. This has two implications: we must decode every bitfield we get AND we have slightly fewer IDs to work with. It goes down from 2040 BBCodes to 1512. We lose like a quarter of them :P P.S. I hope nothing broke :P git-svn-id: file:///svn/phpbb/trunk@6263 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -199,14 +199,7 @@ class dbal
|
||||
}
|
||||
else if (is_string($var))
|
||||
{
|
||||
if (strpos($key, 'bitfield') === false)
|
||||
{
|
||||
$values[] = "'" . $this->sql_escape($var) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$values[] = $this->sql_escape_binary($var);
|
||||
}
|
||||
$values[] = "'" . $this->sql_escape($var) . "'";
|
||||
}
|
||||
else if (is_array($var) && is_string($var[0]))
|
||||
{
|
||||
|
@@ -256,7 +256,7 @@ class dbal_mssql extends dbal
|
||||
{
|
||||
foreach ($row as $key => $value)
|
||||
{
|
||||
$row[$key] = ($value === ' ' && strpos($key, 'bitfield') === false) ? '' : $value;
|
||||
$row[$key] = ($value === ' ') ? '' : $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,14 +369,6 @@ class dbal_mssql extends dbal
|
||||
return str_replace("'", "''", $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string used in sql query
|
||||
*/
|
||||
function sql_escape_binary($msg)
|
||||
{
|
||||
return "CAST('" . $msg . "' AS varbinary)";
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access: private
|
||||
|
@@ -379,14 +379,6 @@ class dbal_mssql_odbc extends dbal
|
||||
return str_replace("'", "''", $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string used in sql query
|
||||
*/
|
||||
function sql_escape_binary($msg)
|
||||
{
|
||||
return "CAST('" . $msg . "' AS varbinary)";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access: private
|
||||
|
@@ -328,16 +328,6 @@ class dbal_mysql extends dbal
|
||||
return @mysql_real_escape_string($msg, $this->db_connect_id);
|
||||
}
|
||||
|
||||
function sql_escape_binary($msg)
|
||||
{
|
||||
// If the last char is
|
||||
if (substr($msg, -1) == ' ')
|
||||
{
|
||||
$msg .= "\0";
|
||||
}
|
||||
return "'" . $this->sql_escape($msg) . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access: private
|
||||
|
@@ -331,16 +331,6 @@ class dbal_mysql4 extends dbal
|
||||
return @mysql_real_escape_string($msg, $this->db_connect_id);
|
||||
}
|
||||
|
||||
function sql_escape_binary($msg)
|
||||
{
|
||||
// If the last char is
|
||||
if (substr($msg, -1) == ' ')
|
||||
{
|
||||
$msg .= "\0";
|
||||
}
|
||||
return "'" . $this->sql_escape($msg) . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access: private
|
||||
|
@@ -311,16 +311,6 @@ class dbal_mysqli extends dbal
|
||||
return @mysqli_real_escape_string($this->db_connect_id, $msg);
|
||||
}
|
||||
|
||||
function sql_escape_binary($msg)
|
||||
{
|
||||
// If the last char is
|
||||
if (substr($msg, -1) == ' ')
|
||||
{
|
||||
$msg .= "\0";
|
||||
}
|
||||
return "'" . $this->sql_escape($msg) . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access: private
|
||||
|
@@ -396,14 +396,6 @@ class dbal_postgres extends dbal
|
||||
return @pg_escape_string($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string used in sql query
|
||||
*/
|
||||
function sql_escape_binary($msg)
|
||||
{
|
||||
return "'" . @pg_escape_bytea($msg) . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access: private
|
||||
|
@@ -49,7 +49,6 @@ class dbal_sqlite extends dbal
|
||||
@sqlite_query('PRAGMA short_column_names = 1', $this->db_connect_id);
|
||||
}
|
||||
|
||||
sqlite_create_function($this->db_connect_id, 'binary_insert', array('dbal_sqlite', '_sql_insert'), 1);
|
||||
|
||||
return ($this->db_connect_id) ? true : array('message' => $error);
|
||||
}
|
||||
@@ -217,13 +216,6 @@ class dbal_sqlite extends dbal
|
||||
}
|
||||
|
||||
$row = @sqlite_fetch_array($query_id, SQLITE_ASSOC);
|
||||
if ($row)
|
||||
{
|
||||
foreach ($row as $key => $value)
|
||||
{
|
||||
$row[$key] = (strpos($key, 'bitfield') === false) ? $value : sqlite_udf_decode_binary($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
@@ -316,14 +308,6 @@ class dbal_sqlite extends dbal
|
||||
return @sqlite_escape_string($msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string used in sql query
|
||||
*/
|
||||
function sql_escape_binary($msg)
|
||||
{
|
||||
return "'" . @sqlite_udf_encode_binary($msg) . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access: private
|
||||
@@ -384,31 +368,6 @@ class dbal_sqlite extends dbal
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the proper binary string used for the default
|
||||
* @access: private
|
||||
*/
|
||||
function _sql_insert($mode)
|
||||
{
|
||||
if ($mode == 1)
|
||||
{
|
||||
$bitfield = new bitfield();
|
||||
$bitfield->set(0);
|
||||
$bitfield->set(3);
|
||||
$bitfield->set(8);
|
||||
$bitfield->set(9);
|
||||
$bitfield->set(11);
|
||||
$bitfield->set(12);
|
||||
return sqlite_udf_encode_binary($bitfield->data);
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
return sqlite_udf_encode_binary("\0");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // if ... define
|
||||
|
Reference in New Issue
Block a user