mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-20 22:39:55 +02:00
Merge pull request #3220 from nickvergessen/ticket/13421
Ticket/13421 Introduce an interface for db\tools.php
This commit is contained in:
commit
d22fa412c4
@ -10,7 +10,7 @@ services:
|
||||
- [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]]
|
||||
|
||||
dbal.tools:
|
||||
class: phpbb\db\tools
|
||||
class: phpbb\db\tools\tools
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
|
||||
|
@ -49,9 +49,9 @@ $classes = $finder->core_path('phpbb/')
|
||||
->get_classes();
|
||||
|
||||
$db = new \phpbb\db\driver\sqlite();
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$schema_data = $schema_generator->get_schema();
|
||||
$dbms_type_map = phpbb\db\tools::get_dbms_type_map();
|
||||
$dbms_type_map = phpbb\db\tools\tools::get_dbms_type_map();
|
||||
|
||||
$fp = fopen($schema_path . 'schema.json', 'wb');
|
||||
fwrite($fp, json_encode($schema_data, JSON_PRETTY_PRINT));
|
||||
|
@ -63,9 +63,9 @@ echo "USE $dbname;$newline$newline";
|
||||
@set_time_limit(0);
|
||||
|
||||
require($phpbb_root_path . 'includes/db/schema_data.' . $phpEx);
|
||||
require($phpbb_root_path . 'phpbb/db/tools.' . $phpEx);
|
||||
require($phpbb_root_path . 'phpbb/db/tools/tools.' . $phpEx);
|
||||
|
||||
$dbms_type_map = phpbb\db\tools::get_dbms_type_map();
|
||||
$dbms_type_map = phpbb\db\tools\tools::get_dbms_type_map();
|
||||
|
||||
foreach ($schema_data as $table_name => $table_data)
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ class acp_database
|
||||
global $cache, $db, $user, $auth, $template, $table_prefix;
|
||||
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
|
||||
|
||||
$this->db_tools = new \phpbb\db\tools($db);
|
||||
$this->db_tools = new \phpbb\db\tools\tools($db);
|
||||
|
||||
$user->add_lang('acp/database');
|
||||
|
||||
|
@ -188,7 +188,7 @@ function dbms_select($default = '', $only_20x_options = false)
|
||||
*/
|
||||
function get_tables(&$db)
|
||||
{
|
||||
$db_tools = new \phpbb\db\tools($db);
|
||||
$db_tools = new \phpbb\db\tools\tools($db);
|
||||
|
||||
return $db_tools->sql_list_tables();
|
||||
}
|
||||
|
@ -1926,7 +1926,7 @@ function phpbb_check_username_collisions()
|
||||
function phpbb_convert_timezone($timezone)
|
||||
{
|
||||
global $config, $db, $phpbb_root_path, $phpEx, $table_prefix;
|
||||
$timezone_migration = new \phpbb\db\migration\data\v310\timezone($config, $db, new \phpbb\db\tools($db), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$timezone_migration = new \phpbb\db\migration\data\v310\timezone($config, $db, new \phpbb\db\tools\tools($db), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
return $timezone_migration->convert_phpbb30_timezone($timezone, 0);
|
||||
}
|
||||
|
||||
|
@ -1197,7 +1197,7 @@ class install_install extends module
|
||||
->get_classes();
|
||||
|
||||
$sqlite_db = new \phpbb\db\driver\sqlite();
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $sqlite_db, new \phpbb\db\tools($sqlite_db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $sqlite_db, new \phpbb\db\tools\tools($sqlite_db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$db_table_schema = $schema_generator->get_schema();
|
||||
}
|
||||
|
||||
@ -1209,7 +1209,7 @@ class install_install extends module
|
||||
define('CONFIG_TABLE', $data['table_prefix'] . 'config');
|
||||
}
|
||||
|
||||
$db_tools = new \phpbb\db\tools($db);
|
||||
$db_tools = new \phpbb\db\tools\tools($db);
|
||||
foreach ($db_table_schema as $table_name => $table_data)
|
||||
{
|
||||
$db_tools->sql_create_table(
|
||||
|
@ -115,7 +115,7 @@ class qa
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db_tool = new \phpbb\db\tools($db);
|
||||
$db_tool = new \phpbb\db\tools\tools($db);
|
||||
|
||||
return $db_tool->sql_table_exists($this->table_captcha_questions);
|
||||
}
|
||||
@ -308,7 +308,7 @@ class qa
|
||||
{
|
||||
global $db;
|
||||
|
||||
$db_tool = new \phpbb\db\tools($db);
|
||||
$db_tool = new \phpbb\db\tools\tools($db);
|
||||
|
||||
$tables = array($this->table_captcha_questions, $this->table_captcha_answers, $this->table_qa_confirm);
|
||||
|
||||
|
@ -34,7 +34,7 @@ class release_3_0_9_rc1 extends \phpbb\db\migration\migration
|
||||
// this column was removed from the database updater
|
||||
// after 3.0.9-RC3 was released. It might still exist
|
||||
// in 3.0.9-RCX installations and has to be dropped as
|
||||
// soon as the db_tools class is capable of properly
|
||||
// soon as the \phpbb\db\tools\tools class is capable of properly
|
||||
// removing a primary key.
|
||||
// 'attempt_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'attempt_ip' => array('VCHAR:40', ''),
|
||||
|
@ -28,7 +28,7 @@ abstract class migration
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\db\tools */
|
||||
/** @var \phpbb\db\tools\tools_interface */
|
||||
protected $db_tools;
|
||||
|
||||
/** @var string */
|
||||
@ -51,12 +51,12 @@ abstract class migration
|
||||
*
|
||||
* @param \phpbb\config\config $config
|
||||
* @param \phpbb\db\driver\driver_interface $db
|
||||
* @param \phpbb\db\tools $db_tools
|
||||
* @param \phpbb\db\tools\tools_interface $db_tools
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
* @param string $table_prefix
|
||||
*/
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
|
@ -24,7 +24,7 @@ class schema_generator
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\db\tools */
|
||||
/** @var \phpbb\db\tools\tools_interface */
|
||||
protected $db_tools;
|
||||
|
||||
/** @var array */
|
||||
@ -48,7 +48,7 @@ class schema_generator
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct(array $class_names, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
|
||||
public function __construct(array $class_names, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $phpbb_root_path, $php_ext, $table_prefix)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
|
@ -24,7 +24,7 @@ class migrator
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\db\tools */
|
||||
/** @var \phpbb\db\tools\tools_interface */
|
||||
protected $db_tools;
|
||||
|
||||
/** @var \phpbb\db\migration\helper */
|
||||
@ -84,7 +84,7 @@ class migrator
|
||||
/**
|
||||
* Constructor of the database migrator
|
||||
*/
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools, \phpbb\db\migration\helper $helper)
|
||||
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools\tools_interface $db_tools, $migrations_table, $phpbb_root_path, $php_ext, $table_prefix, $tools, \phpbb\db\migration\helper $helper)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->db = $db;
|
||||
|
@ -11,13 +11,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db;
|
||||
namespace phpbb\db\tools;
|
||||
|
||||
/**
|
||||
* Database Tools for handling cross-db actions such as altering columns, etc.
|
||||
* Currently not supported is returning SQL for creating tables.
|
||||
*/
|
||||
class tools
|
||||
class tools implements tools_interface
|
||||
{
|
||||
/**
|
||||
* Current sql layer
|
||||
@ -371,10 +371,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of tables in the database.
|
||||
*
|
||||
* @return array Array of table names (all lower case)
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_list_tables()
|
||||
{
|
||||
switch ($this->db->get_sql_layer())
|
||||
@ -431,12 +429,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if table exists
|
||||
*
|
||||
*
|
||||
* @param string $table_name The table name to check for
|
||||
* @return bool true if table exists, else false
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_table_exists($table_name)
|
||||
{
|
||||
$this->db->sql_return_on_error(true);
|
||||
@ -453,12 +447,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Create SQL Table
|
||||
*
|
||||
* @param string $table_name The table name to create
|
||||
* @param array $table_data Array containing table data.
|
||||
* @return array Statements if $return_statements is true.
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_create_table($table_name, $table_data)
|
||||
{
|
||||
// holds the DDL for a column
|
||||
@ -679,27 +669,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle passed database update array.
|
||||
* Expected structure...
|
||||
* Key being one of the following
|
||||
* drop_tables: Drop tables
|
||||
* add_tables: Add tables
|
||||
* change_columns: Column changes (only type, not name)
|
||||
* add_columns: Add columns to a table
|
||||
* drop_keys: Dropping keys
|
||||
* drop_columns: Removing/Dropping columns
|
||||
* add_primary_keys: adding primary keys
|
||||
* add_unique_index: adding an unique index
|
||||
* add_index: adding an index (can be column:index_size if you need to provide size)
|
||||
*
|
||||
* The values are in this format:
|
||||
* {TABLE NAME} => array(
|
||||
* {COLUMN NAME} => array({COLUMN TYPE}, {DEFAULT VALUE}, {OPTIONAL VARIABLES}),
|
||||
* {KEY/INDEX NAME} => array({COLUMN NAMES}),
|
||||
* )
|
||||
*
|
||||
* For more information have a look at /develop/create_schema_files.php (only available through SVN)
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function perform_schema_changes($schema_changes)
|
||||
{
|
||||
if (empty($schema_changes))
|
||||
@ -1079,13 +1050,9 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of columns of a table.
|
||||
*
|
||||
* @param string $table Table name
|
||||
*
|
||||
* @return array Array of column names (all lower case)
|
||||
*/
|
||||
function sql_list_columns($table)
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_list_columns($table_name)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
@ -1093,7 +1060,7 @@ class tools
|
||||
{
|
||||
case 'mysql_40':
|
||||
case 'mysql_41':
|
||||
$sql = "SHOW COLUMNS FROM $table";
|
||||
$sql = "SHOW COLUMNS FROM $table_name";
|
||||
break;
|
||||
|
||||
// PostgreSQL has a way of doing this in a much simpler way but would
|
||||
@ -1101,7 +1068,7 @@ class tools
|
||||
case 'postgres':
|
||||
$sql = "SELECT a.attname
|
||||
FROM pg_class c, pg_attribute a
|
||||
WHERE c.relname = '{$table}'
|
||||
WHERE c.relname = '{$table_name}'
|
||||
AND a.attnum > 0
|
||||
AND a.attrelid = c.oid";
|
||||
break;
|
||||
@ -1113,13 +1080,13 @@ class tools
|
||||
$sql = "SELECT c.name
|
||||
FROM syscolumns c
|
||||
LEFT JOIN sysobjects o ON c.id = o.id
|
||||
WHERE o.name = '{$table}'";
|
||||
WHERE o.name = '{$table_name}'";
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
$sql = "SELECT column_name
|
||||
FROM user_tab_columns
|
||||
WHERE LOWER(table_name) = '" . strtolower($table) . "'";
|
||||
WHERE LOWER(table_name) = '" . strtolower($table_name) . "'";
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
@ -1127,7 +1094,7 @@ class tools
|
||||
$sql = "SELECT sql
|
||||
FROM sqlite_master
|
||||
WHERE type = 'table'
|
||||
AND name = '{$table}'";
|
||||
AND name = '{$table_name}'";
|
||||
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
@ -1173,28 +1140,18 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a specified column exist in a table
|
||||
*
|
||||
* @param string $table Table to check
|
||||
* @param string $column_name Column to check
|
||||
*
|
||||
* @return bool True if column exists, false otherwise
|
||||
*/
|
||||
function sql_column_exists($table, $column_name)
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_column_exists($table_name, $column_name)
|
||||
{
|
||||
$columns = $this->sql_list_columns($table);
|
||||
$columns = $this->sql_list_columns($table_name);
|
||||
|
||||
return isset($columns[$column_name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a specified index exists in table. Does not return PRIMARY KEY and UNIQUE indexes.
|
||||
*
|
||||
* @param string $table_name Table to check the index at
|
||||
* @param string $index_name The index name to check
|
||||
*
|
||||
* @return bool True if index exists, else false
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_index_exists($table_name, $index_name)
|
||||
{
|
||||
if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative')
|
||||
@ -1285,13 +1242,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a specified index exists in table. Does not return PRIMARY KEY indexes.
|
||||
*
|
||||
* @param string $table_name Table to check the index at
|
||||
* @param string $index_name The index name to check
|
||||
*
|
||||
* @return bool True if index exists, else false
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_unique_index_exists($table_name, $index_name)
|
||||
{
|
||||
if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative')
|
||||
@ -1684,8 +1636,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new column
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_column_add($table_name, $column_name, $column_data, $inline = false)
|
||||
{
|
||||
$column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data);
|
||||
@ -1802,8 +1754,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop column
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_column_remove($table_name, $column_name, $inline = false)
|
||||
{
|
||||
$statements = array();
|
||||
@ -1931,8 +1883,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop Index
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_index_drop($table_name, $index_name)
|
||||
{
|
||||
$statements = array();
|
||||
@ -1961,8 +1913,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_table_drop($table_name)
|
||||
{
|
||||
$statements = array();
|
||||
@ -2014,8 +1966,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Add primary key
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_create_primary_key($table_name, $column, $inline = false)
|
||||
{
|
||||
$statements = array();
|
||||
@ -2098,8 +2050,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Add unique index
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_create_unique_index($table_name, $index_name, $column)
|
||||
{
|
||||
$statements = array();
|
||||
@ -2135,8 +2087,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Add index
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_create_index($table_name, $index_name, $column)
|
||||
{
|
||||
$statements = array();
|
||||
@ -2188,11 +2140,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* List all of the indices that belong to a table,
|
||||
* does not count:
|
||||
* * UNIQUE indices
|
||||
* * PRIMARY keys
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_list_index($table_name)
|
||||
{
|
||||
$index_array = array();
|
||||
@ -2287,8 +2236,8 @@ class tools
|
||||
}
|
||||
|
||||
/**
|
||||
* Change column type (not name!)
|
||||
*/
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_column_change($table_name, $column_name, $column_data, $inline = false)
|
||||
{
|
||||
$original_column_data = $column_data;
|
202
phpBB/phpbb/db/tools/tools_interface.php
Normal file
202
phpBB/phpbb/db/tools/tools_interface.php
Normal file
@ -0,0 +1,202 @@
|
||||
<?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\tools;
|
||||
|
||||
/**
|
||||
* Interface for a Database Tools for handling cross-db actions such as altering columns, etc.
|
||||
*/
|
||||
interface tools_interface
|
||||
{
|
||||
/**
|
||||
* Handle passed database update array.
|
||||
* Expected structure...
|
||||
* Key being one of the following
|
||||
* drop_tables: Drop tables
|
||||
* add_tables: Add tables
|
||||
* change_columns: Column changes (only type, not name)
|
||||
* add_columns: Add columns to a table
|
||||
* drop_keys: Dropping keys
|
||||
* drop_columns: Removing/Dropping columns
|
||||
* add_primary_keys: adding primary keys
|
||||
* add_unique_index: adding an unique index
|
||||
* add_index: adding an index (can be column:index_size if you need to provide size)
|
||||
*
|
||||
* The values are in this format:
|
||||
* {TABLE NAME} => array(
|
||||
* {COLUMN NAME} => array({COLUMN TYPE}, {DEFAULT VALUE}, {OPTIONAL VARIABLES}),
|
||||
* {KEY/INDEX NAME} => array({COLUMN NAMES}),
|
||||
* )
|
||||
*
|
||||
*
|
||||
* @param array $schema_changes
|
||||
* @return null
|
||||
*/
|
||||
public function perform_schema_changes($schema_changes);
|
||||
|
||||
/**
|
||||
* Gets a list of tables in the database.
|
||||
*
|
||||
* @return array Array of table names (all lower case)
|
||||
*/
|
||||
public function sql_list_tables();
|
||||
|
||||
/**
|
||||
* Check if table exists
|
||||
*
|
||||
* @param string $table_name The table name to check for
|
||||
* @return bool true if table exists, else false
|
||||
*/
|
||||
public function sql_table_exists($table_name);
|
||||
|
||||
/**
|
||||
* Create SQL Table
|
||||
*
|
||||
* @param string $table_name The table name to create
|
||||
* @param array $table_data Array containing table data.
|
||||
* @return array|true Statements to run, or true if the statements have been executed
|
||||
*/
|
||||
public function sql_create_table($table_name, $table_data);
|
||||
|
||||
/**
|
||||
* Drop Table
|
||||
*
|
||||
* @param string $table_name The table name to drop
|
||||
* @return array|true Statements to run, or true if the statements have been executed
|
||||
*/
|
||||
public function sql_table_drop($table_name);
|
||||
|
||||
/**
|
||||
* Gets a list of columns of a table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
* @return array Array of column names (all lower case)
|
||||
*/
|
||||
public function sql_list_columns($table_name);
|
||||
|
||||
/**
|
||||
* Check whether a specified column exist in a table
|
||||
*
|
||||
* @param string $table_name Table to check
|
||||
* @param string $column_name Column to check
|
||||
* @return bool True if column exists, false otherwise
|
||||
*/
|
||||
public function sql_column_exists($table_name, $column_name);
|
||||
|
||||
/**
|
||||
* Add new column
|
||||
*
|
||||
* @param string $table_name Table to modify
|
||||
* @param string $column_name Name of the column to add
|
||||
* @param array $column_data Column data
|
||||
* @param bool $inline Whether the query should actually be run,
|
||||
* or return a string for adding the column
|
||||
* @return array|true Statements to run, or true if the statements have been executed
|
||||
*/
|
||||
public function sql_column_add($table_name, $column_name, $column_data, $inline = false);
|
||||
|
||||
/**
|
||||
* Change column type (not name!)
|
||||
*
|
||||
* @param string $table_name Table to modify
|
||||
* @param string $column_name Name of the column to modify
|
||||
* @param array $column_data Column data
|
||||
* @param bool $inline Whether the query should actually be run,
|
||||
* or return a string for modifying the column
|
||||
* @return array|true Statements to run, or true if the statements have been executed
|
||||
*/
|
||||
public function sql_column_change($table_name, $column_name, $column_data, $inline = false);
|
||||
|
||||
/**
|
||||
* Drop column
|
||||
*
|
||||
* @param string $table_name Table to modify
|
||||
* @param string $column_name Name of the column to drop
|
||||
* @param bool $inline Whether the query should actually be run,
|
||||
* or return a string for deleting the column
|
||||
* @return array|true Statements to run, or true if the statements have been executed
|
||||
*/
|
||||
public function sql_column_remove($table_name, $column_name, $inline = false);
|
||||
|
||||
/**
|
||||
* List all of the indices that belong to a table
|
||||
*
|
||||
* NOTE: does not list
|
||||
* - UNIQUE indices
|
||||
* - PRIMARY keys
|
||||
*
|
||||
* @param string $table_name Table to check
|
||||
* @return array Array with index names
|
||||
*/
|
||||
public function sql_list_index($table_name);
|
||||
|
||||
/**
|
||||
* Check if a specified index exists in table. Does not return PRIMARY KEY and UNIQUE indexes.
|
||||
*
|
||||
* @param string $table_name Table to check the index at
|
||||
* @param string $index_name The index name to check
|
||||
* @return bool True if index exists, else false
|
||||
*/
|
||||
public function sql_index_exists($table_name, $index_name);
|
||||
|
||||
/**
|
||||
* Add index
|
||||
*
|
||||
* @param string $table_name Table to modify
|
||||
* @param string $index_name Name of the index to create
|
||||
* @param string|array $column Either a string with a column name, or an array with columns
|
||||
* @return array|true Statements to run, or true if the statements have been executed
|
||||
*/
|
||||
public function sql_create_index($table_name, $index_name, $column);
|
||||
|
||||
/**
|
||||
* Drop Index
|
||||
*
|
||||
* @param string $table_name Table to modify
|
||||
* @param string $index_name Name of the index to delete
|
||||
* @return array|true Statements to run, or true if the statements have been executed
|
||||
*/
|
||||
public function sql_index_drop($table_name, $index_name);
|
||||
|
||||
/**
|
||||
* Check if a specified index exists in table.
|
||||
*
|
||||
* NOTE: Does not return normal and PRIMARY KEY indexes
|
||||
*
|
||||
* @param string $table_name Table to check the index at
|
||||
* @param string $index_name The index name to check
|
||||
* @return bool True if index exists, else false
|
||||
*/
|
||||
public function sql_unique_index_exists($table_name, $index_name);
|
||||
|
||||
/**
|
||||
* Add unique index
|
||||
*
|
||||
* @param string $table_name Table to modify
|
||||
* @param string $index_name Name of the unique index to create
|
||||
* @param string|array $column Either a string with a column name, or an array with columns
|
||||
* @return array|true Statements to run, or true if the statements have been executed
|
||||
*/
|
||||
public function sql_create_unique_index($table_name, $index_name, $column);
|
||||
|
||||
/**
|
||||
* Add primary key
|
||||
*
|
||||
* @param string $table_name Table to modify
|
||||
* @param string|array $column Either a string with a column name, or an array with columns
|
||||
* @param bool $inline Whether the query should actually be run,
|
||||
* or return a string for creating the key
|
||||
* @return array|true Statements to run, or true if the statements have been executed
|
||||
*/
|
||||
public function sql_create_primary_key($table_name, $column, $inline = false);
|
||||
}
|
@ -85,7 +85,7 @@ class fulltext_sphinx
|
||||
|
||||
/**
|
||||
* Database Tools object
|
||||
* @var \phpbb\db\tools
|
||||
* @var \phpbb\db\tools\tools_interface
|
||||
*/
|
||||
protected $db_tools;
|
||||
|
||||
@ -135,8 +135,8 @@ class fulltext_sphinx
|
||||
$this->db = $db;
|
||||
$this->auth = $auth;
|
||||
|
||||
// Initialize \phpbb\db\tools object
|
||||
$this->db_tools = new \phpbb\db\tools($this->db);
|
||||
// Initialize \phpbb\db\tools\tools object
|
||||
$this->db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
|
||||
if(!$this->config['fulltext_sphinx_id'])
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case
|
||||
parent::setUp();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$this->tools = new \phpbb\db\tools($this->db);
|
||||
$this->tools = new \phpbb\db\tools\tools($this->db);
|
||||
|
||||
$this->table_data = array(
|
||||
'COLUMNS' => array(
|
||||
|
@ -17,7 +17,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
||||
{
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
/** @var \phpbb\db\tools */
|
||||
/** @var \phpbb\db\tools\tools_interface */
|
||||
protected $tools;
|
||||
protected $table_exists;
|
||||
protected $table_data;
|
||||
@ -32,7 +32,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
||||
parent::setUp();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$this->tools = new \phpbb\db\tools($this->db);
|
||||
$this->tools = new \phpbb\db\tools\tools($this->db);
|
||||
|
||||
$this->table_data = array(
|
||||
'COLUMNS' => array(
|
||||
@ -340,7 +340,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
||||
|
||||
public function test_perform_schema_changes_drop_tables()
|
||||
{
|
||||
$db_tools = $this->getMock('\phpbb\db\tools', array(
|
||||
$db_tools = $this->getMock('\phpbb\db\tools\tools', array(
|
||||
'sql_table_exists',
|
||||
'sql_table_drop',
|
||||
), array(&$this->db));
|
||||
@ -366,7 +366,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
||||
|
||||
public function test_perform_schema_changes_drop_columns()
|
||||
{
|
||||
$db_tools = $this->getMock('\phpbb\db\tools', array(
|
||||
$db_tools = $this->getMock('\phpbb\db\tools\tools', array(
|
||||
'sql_column_exists',
|
||||
'sql_column_remove',
|
||||
), array(&$this->db));
|
||||
|
@ -38,7 +38,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
parent::setUp();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$this->db_tools = new \phpbb\db\tools($this->db);
|
||||
$this->db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
|
||||
$this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache, 'phpbb_config');
|
||||
|
||||
|
@ -150,7 +150,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
|
||||
|
||||
$config = new \phpbb\config\config(array('version' => PHPBB_VERSION));
|
||||
$db = $this->new_dbal();
|
||||
$db_tools = new \phpbb\db\tools($db);
|
||||
$db_tools = new \phpbb\db\tools\tools($db);
|
||||
$phpbb_root_path = __DIR__ . './../../phpBB/';
|
||||
$php_ext = 'php';
|
||||
$table_prefix = 'phpbb_';
|
||||
|
@ -41,7 +41,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
|
||||
'version' => '3.1.0',
|
||||
));
|
||||
$this->db = $this->new_dbal();
|
||||
$this->db_tools = new \phpbb\db\tools($this->db);
|
||||
$this->db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
$this->phpbb_root_path = dirname(__FILE__) . '/';
|
||||
$this->phpEx = 'php';
|
||||
$this->user = new \phpbb\user('\phpbb\datetime');
|
||||
|
@ -18,7 +18,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
|
||||
public function getDataSet()
|
||||
{
|
||||
$this->db = $this->new_dbal();
|
||||
$db_tools = new \phpbb\db\tools($this->db);
|
||||
$db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
|
||||
// user_dst doesn't exist anymore, must re-add it to test this
|
||||
$db_tools->sql_column_add('phpbb_users', 'user_dst', array('BOOL', 1));
|
||||
@ -59,7 +59,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
|
||||
$this->migration = new \phpbb\db\migration\data\v310\timezone(
|
||||
new \phpbb\config\config(array()),
|
||||
$this->db,
|
||||
new \phpbb\db\tools($this->db),
|
||||
new \phpbb\db\tools\tools($this->db),
|
||||
$phpbb_root_path,
|
||||
$phpEx,
|
||||
'phpbb_'
|
||||
@ -90,7 +90,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$db_tools = new \phpbb\db\tools($this->db);
|
||||
$db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
|
||||
// Remove the user_dst field again
|
||||
$db_tools->sql_column_remove('phpbb_users', 'user_dst');
|
||||
|
@ -30,7 +30,7 @@ class schema_generator_test extends phpbb_test_case
|
||||
|
||||
$this->config = new \phpbb\config\config(array());
|
||||
$this->db = new \phpbb\db\driver\sqlite();
|
||||
$this->db_tools = new \phpbb\db\tools($this->db);
|
||||
$this->db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
$this->table_prefix = 'phpbb_';
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
|
||||
$this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert(
|
||||
new \phpbb\config\config(array()),
|
||||
$this->db,
|
||||
new \phpbb\db\tools($this->db),
|
||||
new \phpbb\db\tools\tools($this->db),
|
||||
$phpbb_root_path,
|
||||
$phpEx,
|
||||
'phpbb_'
|
||||
|
@ -77,7 +77,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
global $table_prefix;
|
||||
|
||||
$db = new \phpbb\db\driver\sqlite();
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema()));
|
||||
}
|
||||
|
||||
|
@ -370,11 +370,11 @@ class phpbb_database_test_connection_manager
|
||||
->get_classes();
|
||||
|
||||
$db = new \phpbb\db\driver\sqlite();
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$db_table_schema = $schema_generator->get_schema();
|
||||
}
|
||||
|
||||
$db_tools = new \phpbb\db\tools($db, true);
|
||||
$db_tools = new \phpbb\db\tools\tools($db, true);
|
||||
foreach ($db_table_schema as $table_name => $table_data)
|
||||
{
|
||||
$queries = $db_tools->sql_create_table(
|
||||
|
@ -230,7 +230,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
|
||||
$config = new \phpbb\config\config(array());
|
||||
$db = $this->get_db();
|
||||
$db_tools = new \phpbb\db\tools($db);
|
||||
$db_tools = new \phpbb\db\tools\tools($db);
|
||||
|
||||
$migrator = new \phpbb\db\migrator(
|
||||
$config,
|
||||
|
Loading…
x
Reference in New Issue
Block a user