diff options
author | David M <davidmj@users.sourceforge.net> | 2006-07-24 10:08:36 +0000 |
---|---|---|
committer | David M <davidmj@users.sourceforge.net> | 2006-07-24 10:08:36 +0000 |
commit | 9532514c2a566437a9524af1dfca298da58fd40a (patch) | |
tree | 95cd37ebfc723ae45216db69625a1858479c94ba /phpBB/includes/acp/acp_styles.php | |
parent | 48b2dc127761640810a8bbd6c59fd3c5be696778 (diff) | |
download | forums-9532514c2a566437a9524af1dfca298da58fd40a.tar forums-9532514c2a566437a9524af1dfca298da58fd40a.tar.gz forums-9532514c2a566437a9524af1dfca298da58fd40a.tar.bz2 forums-9532514c2a566437a9524af1dfca298da58fd40a.tar.xz forums-9532514c2a566437a9524af1dfca298da58fd40a.zip |
OK...
This commit should increase the total number of BBCodes from 31 to 2040. Some things to watch out for:
Each database likes to deal with binary data in its own, special way. They are, quite frankly, too cool for school.
MySQL, MSSQL and Oracle all allow me to send in a default value for their binary column using a hex number. However, MSSQL forces me to send the specific data as a hex number and thus we must CAST it.
PostgreSQL allows me to set a binary column, but with a twist. It demands that the default be in _octal_ and its datatype allows somewhere around a gigabyte's worth of BBCodes ( PGSQL users, we shut you down to 2040 for your own good! )
Firebird has no decent mechanism for allowing me to shuttle in binary data so I must force my way in. By virtue of triggers and a UDF, we ram in our default values.
SQLite is the most bizarre of them all. They have no mechanism for turning an ASCII code into a ASCII character. Because of this, we have a trigger and a UDF (just like Firebird!) but with a twist! The UDF is defined on the PHP side of things instead of SQL. SQLite also demands that it's data be encoded before being sent off.
Other notes:
- SQLite installs again :D
- Firebird nearly installs again :P
- Database backup is not screwed up :P
P.S.
I hope nothing broke :D
git-svn-id: file:///svn/phpbb/trunk@6209 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/acp/acp_styles.php')
-rw-r--r-- | phpBB/includes/acp/acp_styles.php | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 92bd515f98..2e27995a81 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -27,7 +27,14 @@ class acp_styles global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; // Hardcoded template bitfield to add for new templates - define('TEMPLATE_BITFIELD', 6921); + $bitfield = new bitfield(); + $bitfield->set(0); + $bitfield->set(3); + $bitfield->set(8); + $bitfield->set(9); + $bitfield->set(11); + $bitfield->set(12); + define('TEMPLATE_BITFIELD', $bitfield->data); $user->add_lang('acp/styles'); @@ -2917,10 +2924,78 @@ pagination_sep = \'{PAGINATION_SEP}\' unset($cfg_data); } + $query = ''; + + switch (SQL_LAYER) + { + case 'mssql': + case 'mssql_odbc': + $fields = array(); + foreach ($sql_ary as $key => $var) + { + $fields[] = $key; + + if (is_null($var)) + { + $values[] = 'NULL'; + } + else if (is_string($var)) + { + if ($key !== 'bbcode_bitfield') + { + $values[] = "'" . $db->sql_escape($var) . "'"; + } + else + { + $values[] = "CAST('" . $var . "' AS varbinary)"; + } + } + else + { + $values[] = (is_bool($var)) ? intval($var) : $var; + } + } + $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')'; + break; + + case 'sqlite': + $fields = array(); + foreach ($sql_ary as $key => $var) + { + $fields[] = $key; + + if (is_null($var)) + { + $values[] = 'NULL'; + } + else if (is_string($var)) + { + if ($key !== 'bbcode_bitfield') + { + $values[] = "'" . $db->sql_escape($var) . "'"; + } + else + { + $values[] = "'" . sqlite_udf_encode_binary($var) . "'"; + } + } + else + { + $values[] = (is_bool($var)) ? intval($var) : $var; + } + } + $query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')'; + break; + + default: + $query = $db->sql_build_array('INSERT', $sql_ary); + break; + } + $db->sql_transaction('begin'); $sql = "INSERT INTO $sql_from - " . $db->sql_build_array('INSERT', $sql_ary); + " . $query; $db->sql_query($sql); $id = $db->sql_nextid(); |