[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\install\module\install_database\task; 15 16 /** 17 * Set up database for table generation 18 */ 19 class set_up_database extends \phpbb\install\task_base 20 { 21 /** 22 * @var \phpbb\install\helper\config 23 */ 24 protected $config; 25 26 /** 27 * @var \phpbb\db\driver\driver_interface 28 */ 29 protected $db; 30 31 /** 32 * @var \phpbb\install\helper\database 33 */ 34 protected $database_helper; 35 36 /** 37 * @var \phpbb\filesystem\filesystem_interface 38 */ 39 protected $filesystem; 40 41 /** 42 * @var \phpbb\install\helper\iohandler\iohandler_interface 43 */ 44 protected $iohandler; 45 46 /** 47 * @var string 48 */ 49 protected $schema_file_path; 50 51 /** 52 * @var string 53 */ 54 protected $phpbb_root_path; 55 56 /** 57 * Constructor 58 * 59 * @param \phpbb\install\helper\config $config 60 * @param \phpbb\install\helper\database $db_helper 61 * @param \phpbb\filesystem\filesystem_interface $filesystem 62 * @param \phpbb\install\helper\iohandler\iohandler_interface $iohandler 63 * @param string $phpbb_root_path 64 */ 65 public function __construct(\phpbb\install\helper\config $config, 66 \phpbb\install\helper\database $db_helper, 67 \phpbb\filesystem\filesystem_interface $filesystem, 68 \phpbb\install\helper\iohandler\iohandler_interface $iohandler, 69 $phpbb_root_path) 70 { 71 $dbms = $db_helper->get_available_dbms($config->get('dbms')); 72 $dbms = $dbms[$config->get('dbms')]['DRIVER']; 73 74 $this->db = new $dbms(); 75 $this->db->sql_connect( 76 $config->get('dbhost'), 77 $config->get('dbuser'), 78 $config->get('dbpasswd'), 79 $config->get('dbname'), 80 $config->get('dbport'), 81 false, 82 false 83 ); 84 85 $this->config = $config; 86 $this->database_helper = $db_helper; 87 $this->filesystem = $filesystem; 88 $this->iohandler = $iohandler; 89 $this->phpbb_root_path = $phpbb_root_path; 90 91 parent::__construct(false); 92 } 93 94 /** 95 * {@inheritdoc} 96 */ 97 public function check_requirements() 98 { 99 $dbms = $this->config->get('dbms'); 100 $dbms_info = $this->database_helper->get_available_dbms($dbms); 101 $schema_name = $dbms_info[$dbms]['SCHEMA']; 102 103 if ($dbms === 'mysql') 104 { 105 $schema_name .= '_41'; 106 } 107 108 $this->schema_file_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; 109 110 return $this->filesystem->exists($this->schema_file_path); 111 } 112 113 /** 114 * {@inheritdoc} 115 */ 116 public function run() 117 { 118 $this->db->sql_return_on_error(true); 119 120 $dbms = $this->config->get('dbms'); 121 $dbms_info = $this->database_helper->get_available_dbms($dbms); 122 $delimiter = $dbms_info[$dbms]['DELIM']; 123 $table_prefix = $this->config->get('table_prefix'); 124 125 $sql_query = @file_get_contents($this->schema_file_path); 126 $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); 127 $sql_query = $this->database_helper->remove_comments($sql_query); 128 $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter); 129 130 foreach ($sql_query as $sql) 131 { 132 if (!$this->db->sql_query($sql)) 133 { 134 $error = $this->db->sql_error($this->db->get_sql_error_sql()); 135 $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); 136 } 137 } 138 139 unset($sql_query); 140 } 141 142 /** 143 * {@inheritdoc} 144 */ 145 static public function get_step_count() 146 { 147 return 1; 148 } 149 150 /** 151 * {@inheritdoc} 152 */ 153 public function get_task_lang_name() 154 { 155 return 'TASK_SETUP_DATABASE'; 156 } 157 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |