1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

Merge remote-tracking branch 'github-nicofuma/ticket/12446' into develop-ascraeus

* github-nicofuma/ticket/12446:
  [ticket/12446] Unnecessary db connect inphpbb_bootstrap_enabled_exts
This commit is contained in:
Nils Adermann
2014-07-04 21:08:20 +02:00
55 changed files with 764 additions and 143 deletions

View File

@@ -1043,7 +1043,7 @@ class auth
{
if (strpos($auth_options, '%') !== false)
{
$sql_opts = "AND $key " . $db->sql_like_expression(str_replace('%', $db->any_char, $auth_options));
$sql_opts = "AND $key " . $db->sql_like_expression(str_replace('%', $db->get_any_char(), $auth_options));
}
else
{
@@ -1074,7 +1074,7 @@ class auth
{
if (strpos($option, '%') !== false)
{
$sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->any_char, $option));
$sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->get_any_char(), $option));
}
else
{

View File

@@ -305,7 +305,7 @@ class service
{
if (($bots = $this->driver->get('_bots')) === false)
{
switch ($this->db->sql_layer)
switch ($this->db->get_sql_layer())
{
case 'mssql':
case 'mssql_odbc':

View File

@@ -86,6 +86,102 @@ abstract class driver implements driver_interface
$this->one_char = chr(0) . '_';
}
/**
* {@inheritdoc}
*/
public function get_sql_layer()
{
return $this->sql_layer;
}
/**
* {@inheritdoc}
*/
public function get_db_name()
{
return $this->dbname;
}
/**
* {@inheritdoc}
*/
public function get_any_char()
{
return $this->any_char;
}
/**
* {@inheritdoc}
*/
public function get_one_char()
{
return $this->one_char;
}
/**
* {@inheritdoc}
*/
public function get_db_connect_id()
{
return $this->db_connect_id;
}
/**
* {@inheritdoc}
*/
public function get_sql_error_triggered()
{
return $this->sql_error_triggered;
}
/**
* {@inheritdoc}
*/
public function get_sql_error_sql()
{
return $this->sql_error_sql;
}
/**
* {@inheritdoc}
*/
public function get_transaction()
{
return $this->transaction;
}
/**
* {@inheritdoc}
*/
public function get_sql_time()
{
return $this->sql_time;
}
/**
* {@inheritdoc}
*/
public function get_sql_error_returned()
{
return $this->sql_error_returned;
}
/**
* {@inheritdoc}
*/
public function get_multi_insert()
{
return $this->multi_insert;
}
/**
* {@inheritdoc}
*/
public function set_multi_insert($multi_insert)
{
$this->multi_insert = $multi_insert;
}
/**
* {@inheritDoc}
*/

View File

@@ -15,6 +15,90 @@ namespace phpbb\db\driver;
interface driver_interface
{
/**
* Gets the name of the sql layer.
*
* @return string
*/
public function get_sql_layer();
/**
* Gets the name of the database.
*
* @return string
*/
public function get_db_name();
/**
* Wildcards for matching any (%) character within LIKE expressions
*
* @return string
*/
public function get_any_char();
/**
* Wildcards for matching exactly one (_) character within LIKE expressions
*
* @return string
*/
public function get_one_char();
/**
* Gets the time spent into the queries
*
* @return int
*/
public function get_sql_time();
/**
* Gets the connect ID.
*
* @return mixed
*/
public function get_db_connect_id();
/**
* Indicates if an error was triggered.
*
* @return bool
*/
public function get_sql_error_triggered();
/**
* Gets the last faulty query
*
* @return string
*/
public function get_sql_error_sql();
/**
* Indicates if we are in a transaction.
*
* @return bool
*/
public function get_transaction();
/**
* Gets the returned error.
*
* @return array
*/
public function get_sql_error_returned();
/**
* Indicates if multiple insertion can be used
*
* @return bool
*/
public function get_multi_insert();
/**
* Set if multiple insertion can be used
*
* @param bool $multi_insert
*/
public function set_multi_insert($multi_insert);
/**
* Gets the exact number of rows in a specified table.
*

View File

@@ -0,0 +1,435 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\driver;
use \Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Database Abstraction Layer
*/
class factory implements driver_interface
{
/**
* @var driver_interface
*/
protected $driver = null;
/**
* @var ContainerInterface
*/
protected $container;
/**
* Constructor.
*
* @param ContainerInterface $container A ContainerInterface instance
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
/**
* Return the current driver (and retrieved it from the container if necessary)
*
* @return driver_interface
*/
protected function get_driver()
{
if ($this->driver === null)
{
$this->driver = $this->container->get('dbal.conn.driver');
}
return $this->driver;
}
/**
* Set the current driver
*
* @param driver_interface $driver
*/
public function set_driver(driver_interface $driver)
{
$this->driver = $driver;
}
/**
* {@inheritdoc}
*/
public function get_sql_layer()
{
return $this->get_driver()->get_sql_layer();
}
/**
* {@inheritdoc}
*/
public function get_db_name()
{
return $this->get_driver()->get_db_name();
}
/**
* {@inheritdoc}
*/
public function get_any_char()
{
return $this->get_driver()->get_any_char();
}
/**
* {@inheritdoc}
*/
public function get_one_char()
{
return $this->get_driver()->get_one_char();
}
/**
* {@inheritdoc}
*/
public function get_db_connect_id()
{
return $this->get_driver()->get_db_connect_id();
}
/**
* {@inheritdoc}
*/
public function get_sql_error_triggered()
{
return $this->get_driver()->get_sql_error_triggered();
}
/**
* {@inheritdoc}
*/
public function get_sql_error_sql()
{
return $this->get_driver()->get_sql_error_sql();
}
/**
* {@inheritdoc}
*/
public function get_transaction()
{
return $this->get_driver()->get_transaction();
}
/**
* {@inheritdoc}
*/
public function get_sql_time()
{
return $this->get_driver()->get_sql_time();
}
/**
* {@inheritdoc}
*/
public function get_sql_error_returned()
{
return $this->get_driver()->get_sql_error_returned();
}
/**
* {@inheritdoc}
*/
public function get_multi_insert()
{
return $this->get_driver()->get_multi_insert();
}
/**
* {@inheritdoc}
*/
public function set_multi_insert($multi_insert)
{
$this->get_driver()->set_multi_insert($multi_insert);
}
/**
* {@inheritdoc}
*/
public function get_row_count($table_name)
{
return $this->get_driver()->get_row_count($table_name);
}
/**
* {@inheritdoc}
*/
public function get_estimated_row_count($table_name)
{
return $this->get_driver()->get_estimated_row_count($table_name);
}
/**
* {@inheritdoc}
*/
public function sql_lower_text($column_name)
{
return $this->get_driver()->sql_lower_text($column_name);
}
/**
* {@inheritdoc}
*/
public function sql_error($sql = '')
{
return $this->get_driver()->sql_error($sql);
}
/**
* {@inheritdoc}
*/
public function sql_buffer_nested_transactions()
{
return $this->get_driver()->sql_buffer_nested_transactions();
}
/**
* {@inheritdoc}
*/
public function sql_bit_or($column_name, $bit, $compare = '')
{
return $this->get_driver()->sql_bit_or($column_name, $bit, $compare);
}
/**
* {@inheritdoc}
*/
public function sql_server_info($raw = false, $use_cache = true)
{
return $this->get_driver()->sql_server_info($raw, $use_cache);
}
/**
* {@inheritdoc}
*/
public function sql_return_on_error($fail = false)
{
return $this->get_driver()->sql_return_on_error($fail);
}
/**
* {@inheritdoc}
*/
public function sql_build_array($query, $assoc_ary = array())
{
return $this->get_driver()->sql_build_array($query, $assoc_ary);
}
/**
* {@inheritdoc}
*/
public function sql_fetchrowset($query_id = false)
{
return $this->get_driver()->sql_fetchrowset($query_id);
}
/**
* {@inheritdoc}
*/
public function sql_transaction($status = 'begin')
{
return $this->get_driver()->sql_transaction($status);
}
/**
* {@inheritdoc}
*/
public function sql_concatenate($expr1, $expr2)
{
return $this->get_driver()->sql_concatenate($expr1, $expr2);
}
/**
* {@inheritdoc}
*/
public function sql_case($condition, $action_true, $action_false = false)
{
return $this->get_driver()->sql_case($condition, $action_true, $action_false);
}
/**
* {@inheritdoc}
*/
public function sql_build_query($query, $array)
{
return $this->get_driver()->sql_build_query($query, $array);
}
/**
* {@inheritdoc}
*/
public function sql_fetchfield($field, $rownum = false, $query_id = false)
{
return $this->get_driver()->sql_fetchfield($field, $rownum, $query_id);
}
/**
* {@inheritdoc}
*/
public function sql_fetchrow($query_id = false)
{
return $this->get_driver()->sql_fetchrow($query_id);
}
/**
* {@inheritdoc}
*/
public function cast_expr_to_bigint($expression)
{
return $this->get_driver()->cast_expr_to_bigint($expression);
}
/**
* {@inheritdoc}
*/
public function sql_nextid()
{
return $this->get_driver()->sql_nextid();
}
/**
* {@inheritdoc}
*/
public function sql_add_num_queries($cached = false)
{
return $this->get_driver()->sql_add_num_queries($cached);
}
/**
* {@inheritdoc}
*/
public function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
return $this->get_driver()->sql_query_limit($query, $total, $offset, $cache_ttl);
}
/**
* {@inheritdoc}
*/
public function sql_query($query = '', $cache_ttl = 0)
{
return $this->get_driver()->sql_query($query, $cache_ttl);
}
/**
* {@inheritdoc}
*/
public function cast_expr_to_string($expression)
{
return $this->get_driver()->cast_expr_to_string($expression);
}
/**
* {@inheritdoc}
*/
public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
throw new \Exception('Disabled method.');
}
/**
* {@inheritdoc}
*/
public function sql_bit_and($column_name, $bit, $compare = '')
{
return $this->get_driver()->sql_bit_and($column_name, $bit, $compare);
}
/**
* {@inheritdoc}
*/
public function sql_freeresult($query_id = false)
{
return $this->get_driver()->sql_freeresult($query_id);
}
/**
* {@inheritdoc}
*/
public function sql_num_queries($cached = false)
{
return $this->get_driver()->sql_num_queries($cached);
}
/**
* {@inheritdoc}
*/
public function sql_multi_insert($table, $sql_ary)
{
return $this->get_driver()->sql_multi_insert($table, $sql_ary);
}
/**
* {@inheritdoc}
*/
public function sql_affectedrows()
{
return $this->get_driver()->sql_affectedrows();
}
/**
* {@inheritdoc}
*/
public function sql_close()
{
return $this->get_driver()->sql_close();
}
/**
* {@inheritdoc}
*/
public function sql_rowseek($rownum, &$query_id)
{
return $this->get_driver()->sql_rowseek($rownum, $query_id);
}
/**
* {@inheritdoc}
*/
public function sql_escape($msg)
{
return $this->get_driver()->sql_escape($msg);
}
/**
* {@inheritdoc}
*/
public function sql_like_expression($expression)
{
return $this->get_driver()->sql_like_expression($expression);
}
/**
* {@inheritdoc}
*/
public function sql_report($mode, $query = '')
{
return $this->get_driver()->sql_report($mode, $query);
}
/**
* {@inheritdoc}
*/
public function sql_in_set($field, $array, $negate = false, $allow_empty_set = false)
{
return $this->get_driver()->sql_in_set($field, $array, $negate, $allow_empty_set);
}
}

View File

@@ -37,7 +37,7 @@ class local_url_bbcode extends \phpbb\db\migration\migration
{
$sql = 'SELECT *
FROM ' . BBCODES_TABLE . '
WHERE bbcode_match ' . $this->db->sql_like_expression($this->db->any_char . 'LOCAL_URL' . $this->db->any_char);
WHERE bbcode_match ' . $this->db->sql_like_expression($this->db->get_any_char() . 'LOCAL_URL' . $this->db->get_any_char());
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))

View File

@@ -36,7 +36,7 @@ class release_3_0_4 extends \phpbb\db\migration\migration
public function rename_log_delete_topic()
{
if ($this->db->sql_layer == 'oracle')
if ($this->db->get_sql_layer() == 'oracle')
{
// log_operation is CLOB - but we can change this later
$sql = 'UPDATE ' . $this->table_prefix . "log

View File

@@ -76,7 +76,7 @@ class release_3_0_7_rc1 extends \phpbb\db\migration\migration
{
// Delete all text-templates from the template_data
$sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . '
WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt');
WHERE template_filename ' . $this->db->sql_like_expression($this->db->get_any_char() . '.txt');
$this->sql_query($sql);
}
}

View File

@@ -89,7 +89,7 @@ class release_3_0_9_rc1 extends \phpbb\db\migration\migration
// Update file extension group names to use language strings, again.
$sql = 'SELECT group_id, group_name
FROM ' . EXTENSION_GROUPS_TABLE . '
WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char);
WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->get_any_char());
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))

View File

@@ -18,7 +18,7 @@ class mysql_fulltext_drop extends \phpbb\db\migration\migration
public function effectively_installed()
{
// This migration is irrelevant for all non-MySQL DBMSes.
return strpos($this->db->sql_layer, 'mysql') === false;
return strpos($this->db->get_sql_layer(), 'mysql') === false;
}
static public function depends_on()

View File

@@ -18,7 +18,7 @@ class postgres_fulltext_drop extends \phpbb\db\migration\migration
public function effectively_installed()
{
// This migration is irrelevant for all non-PostgreSQL DBMSes.
return strpos($this->db->sql_layer, 'postgres') === false;
return strpos($this->db->get_sql_layer(), 'postgres') === false;
}
static public function depends_on()

View File

@@ -160,11 +160,11 @@ abstract class migration
else
{
$result = $this->db->sql_query($sql);
if ($this->db->sql_error_triggered)
if ($this->db->get_sql_error_triggered())
{
$this->errors[] = array(
'sql' => $this->db->sql_error_sql,
'code' => $this->db->sql_error_returned,
'sql' => $this->db->get_sql_error_sql(),
'code' => $this->db->get_sql_error_returned(),
);
}
}

View File

@@ -110,7 +110,7 @@ class migrator
FROM " . $this->migrations_table;
$result = $this->db->sql_query($sql);
if (!$this->db->sql_error_triggered)
if (!$this->db->get_sql_error_triggered())
{
while ($migration = $this->db->sql_fetchrow($result))
{

View File

@@ -92,7 +92,7 @@ class sql_insert_buffer
// Flush buffer if it is full or when DB does not support multi inserts.
// In the later case, the buffer will always only contain one row.
if (!$this->db->multi_insert || sizeof($this->buffer) >= $this->max_buffered_rows)
if (!$this->db->get_multi_insert() || sizeof($this->buffer) >= $this->max_buffered_rows)
{
return $this->flush();
}

View File

@@ -323,7 +323,7 @@ class tools
$this->dbms_type_map = self::get_dbms_type_map();
// Determine mapping database type
switch ($this->db->sql_layer)
switch ($this->db->get_sql_layer())
{
case 'mysql':
$this->sql_layer = 'mysql_40';
@@ -354,7 +354,7 @@ class tools
break;
default:
$this->sql_layer = $this->db->sql_layer;
$this->sql_layer = $this->db->get_sql_layer();
break;
}
}
@@ -377,7 +377,7 @@ class tools
*/
function sql_list_tables()
{
switch ($this->db->sql_layer)
switch ($this->db->get_sql_layer())
{
case 'mysql':
case 'mysql4':
@@ -711,7 +711,7 @@ class tools
$sqlite = false;
// For SQLite we need to perform the schema changes in a much more different way
if (($this->db->sql_layer == 'sqlite' || $this->db->sql_layer == 'sqlite3') && $this->return_statements)
if (($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3') && $this->return_statements)
{
$sqlite_data = array();
$sqlite = true;

View File

@@ -737,7 +737,7 @@ class log implements \phpbb\log\log_interface
for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++)
{
$keywords_pattern[] = preg_quote($keywords[$i], '#');
$keywords[$i] = $this->db->sql_like_expression($this->db->any_char . $keywords[$i] . $this->db->any_char);
$keywords[$i] = $this->db->sql_like_expression($this->db->get_any_char() . $keywords[$i] . $this->db->get_any_char());
}
$keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui';

View File

@@ -282,7 +282,7 @@ class base
$sql_where = '';
foreach ($words as $word)
{
$sql_where .= " OR search_keywords " . $db->sql_like_expression($db->any_char . $word . $db->any_char);
$sql_where .= " OR search_keywords " . $db->sql_like_expression($db->get_any_char() . $word . $db->get_any_char());
}
$sql = 'SELECT search_key
@@ -303,7 +303,7 @@ class base
$sql_where = '';
foreach ($authors as $author)
{
$sql_where .= (($sql_where) ? ' OR ' : '') . 'search_authors ' . $db->sql_like_expression($db->any_char . ' ' . (int) $author . ' ' . $db->any_char);
$sql_where .= (($sql_where) ? ' OR ' : '') . 'search_authors ' . $db->sql_like_expression($db->get_any_char() . ' ' . (int) $author . ' ' . $db->get_any_char());
}
$sql = 'SELECT search_key

View File

@@ -140,7 +140,7 @@ class fulltext_mysql extends \phpbb\search\base
*/
public function init()
{
if ($this->db->sql_layer != 'mysql4' && $this->db->sql_layer != 'mysqli')
if ($this->db->get_sql_layer() != 'mysql4' && $this->db->get_sql_layer() != 'mysqli')
{
return $this->user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE'];
}
@@ -764,7 +764,7 @@ class fulltext_mysql extends \phpbb\search\base
if (!isset($this->stats['post_subject']))
{
if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
{
$alter[] = 'MODIFY post_subject varchar(255) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL';
}
@@ -777,7 +777,7 @@ class fulltext_mysql extends \phpbb\search\base
if (!isset($this->stats['post_content']))
{
if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
{
$alter[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL';
}
@@ -872,7 +872,7 @@ class fulltext_mysql extends \phpbb\search\base
*/
protected function get_stats()
{
if (strpos($this->db->sql_layer, 'mysql') === false)
if (strpos($this->db->get_sql_layer(), 'mysql') === false)
{
$this->stats = array();
return;

View File

@@ -758,7 +758,7 @@ class fulltext_native extends \phpbb\search\base
);
}
switch ($this->db->sql_layer)
switch ($this->db->get_sql_layer())
{
case 'mysql4':
case 'mysqli':
@@ -978,7 +978,7 @@ class fulltext_native extends \phpbb\search\base
// If the cache was completely empty count the results
if (!$total_results)
{
switch ($this->db->sql_layer)
switch ($this->db->get_sql_layer())
{
case 'mysql4':
case 'mysqli':
@@ -1000,7 +1000,7 @@ class fulltext_native extends \phpbb\search\base
}
else
{
if ($this->db->sql_layer == 'sqlite' || $this->db->sql_layer == 'sqlite3')
if ($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3')
{
$sql = 'SELECT COUNT(topic_id) as total_results
FROM (SELECT DISTINCT t.topic_id';
@@ -1017,7 +1017,7 @@ class fulltext_native extends \phpbb\search\base
$post_visibility
$sql_fora
AND t.topic_id = p.topic_id
$sql_time" . (($this->db->sql_layer == 'sqlite' || $this->db->sql_layer == 'sqlite3') ? ')' : '');
$sql_time" . (($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3') ? ')' : '');
}
$result = $this->db->sql_query($sql);
@@ -1481,7 +1481,7 @@ class fulltext_native extends \phpbb\search\base
*/
public function delete_index($acp_module, $u_action)
{
switch ($this->db->sql_layer)
switch ($this->db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':

View File

@@ -107,7 +107,7 @@ class fulltext_postgres extends \phpbb\search\base
$this->word_length = array('min' => $this->config['fulltext_postgres_min_word_len'], 'max' => $this->config['fulltext_postgres_max_word_len']);
if ($this->db->sql_layer == 'postgres')
if ($this->db->get_sql_layer() == 'postgres')
{
$pgsql_version = explode(',', substr($this->db->sql_server_info(), 10));
$this->version = trim($pgsql_version[0]);
@@ -185,7 +185,7 @@ class fulltext_postgres extends \phpbb\search\base
*/
public function init()
{
if ($this->db->sql_layer != 'postgres')
if ($this->db->get_sql_layer() != 'postgres')
{
return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE'];
}
@@ -869,7 +869,7 @@ class fulltext_postgres extends \phpbb\search\base
*/
protected function get_stats()
{
if ($this->db->sql_layer != 'postgres')
if ($this->db->get_sql_layer() != 'postgres')
{
$this->stats = array();
return;
@@ -919,7 +919,7 @@ class fulltext_postgres extends \phpbb\search\base
<dt><label>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME_EXPLAIN'] . '</span></dt>
<dd><select name="config[fulltext_postgres_ts_name]">';
if ($this->db->sql_layer == 'postgres' && $this->tsearch_usable)
if ($this->db->get_sql_layer() == 'postgres' && $this->tsearch_usable)
{
$sql = 'SELECT cfgname AS ts_name
FROM pg_ts_config';

View File

@@ -199,7 +199,7 @@ class fulltext_sphinx
*/
public function init()
{
if ($this->db->sql_layer != 'mysql' && $this->db->sql_layer != 'mysql4' && $this->db->sql_layer != 'mysqli' && $this->db->sql_layer != 'postgres')
if ($this->db->get_sql_layer() != 'mysql' && $this->db->get_sql_layer() != 'mysql4' && $this->db->get_sql_layer() != 'mysqli' && $this->db->get_sql_layer() != 'postgres')
{
return $this->user->lang['FULLTEXT_SPHINX_WRONG_DATABASE'];
}
@@ -218,11 +218,11 @@ class fulltext_sphinx
protected function config_generate()
{
// Check if Database is supported by Sphinx
if ($this->db->sql_layer =='mysql' || $this->db->sql_layer == 'mysql4' || $this->db->sql_layer == 'mysqli')
if ($this->db->get_sql_layer() =='mysql' || $this->db->get_sql_layer() == 'mysql4' || $this->db->get_sql_layer() == 'mysqli')
{
$this->dbtype = 'mysql';
}
else if ($this->db->sql_layer == 'postgres')
else if ($this->db->get_sql_layer() == 'postgres')
{
$this->dbtype = 'pgsql';
}