1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-22 19:07:27 +01:00

[feature/sphinx-fulltext-search] implementing db_tools

Use db_tools class for creating/dropping sphinx table.

PHPBB3-10946
This commit is contained in:
Dhruv Goel 2012-07-10 05:23:23 +05:30 committed by Dhruv
parent 79432aa4a0
commit 45c0956bcf

View File

@ -43,6 +43,7 @@ class phpbb_search_fulltext_sphinx
private $auth; private $auth;
private $config; private $config;
private $db; private $db;
private $db_tools;
private $user; private $user;
public $word_length = array(); public $word_length = array();
public $search_query; public $search_query;
@ -56,12 +57,20 @@ class phpbb_search_fulltext_sphinx
*/ */
public function __construct(&$error) public function __construct(&$error)
{ {
global $config, $db, $user, $auth; global $config, $db, $user, $auth, $phpbb_root_path, $phpEx;
$this->config = $config; $this->config = $config;
$this->user = $user; $this->user = $user;
$this->db = $db; $this->db = $db;
$this->auth = $auth; $this->auth = $auth;
if (!class_exists('phpbb_db_tools'))
{
require($phpbb_root_path . 'includes/db/db_tools.' . $phpEx);
}
// Initialize phpbb_db_tools object
$this->db_tools = new phpbb_db_tools($this->db);
$this->id = $config['avatar_salt']; $this->id = $config['avatar_salt'];
$this->indexes = 'index_phpbb_' . $this->id . '_delta;index_phpbb_' . $this->id . '_main'; $this->indexes = 'index_phpbb_' . $this->id . '_delta;index_phpbb_' . $this->id . '_main';
@ -604,11 +613,14 @@ class phpbb_search_fulltext_sphinx
{ {
if (!$this->index_created()) if (!$this->index_created())
{ {
$sql = 'CREATE TABLE IF NOT EXISTS ' . SPHINX_TABLE . ' ( $table_data = array(
counter_id INT NOT NULL PRIMARY KEY, 'COLUMNS' => array(
max_doc_id INT NOT NULL 'counter_id' => array('UINT', 0),
)'; 'max_doc_id' => array('UINT', 0),
$this->db->sql_query($sql); ),
'PRIMARY_KEY' => 'counter_id',
);
$this->db_tools->sql_create_table(SPHINX_TABLE, $table_data);
$sql = 'TRUNCATE TABLE ' . SPHINX_TABLE; $sql = 'TRUNCATE TABLE ' . SPHINX_TABLE;
$this->db->sql_query($sql); $this->db->sql_query($sql);
@ -631,8 +643,7 @@ class phpbb_search_fulltext_sphinx
return false; return false;
} }
$sql = 'DROP TABLE ' . SPHINX_TABLE; $this->db_tools->sql_table_drop(SPHINX_TABLE);
$this->db->sql_query($sql);
return false; return false;
} }