Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
migration.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\db\migration;
015
016 /**
017 * Abstract base class for database migrations
018 *
019 * Each migration consists of a set of schema and data changes to be implemented
020 * in a subclass. This class provides various utility methods to simplify editing
021 * a phpBB.
022 */
023 abstract class migration implements migration_interface
024 {
025 /** @var \phpbb\config\config */
026 protected $config;
027
028 /** @var \phpbb\db\driver\driver_interface */
029 protected $db;
030
031 /** @var \phpbb\db\tools\tools_interface */
032 protected $db_tools;
033
034 /** @var string */
035 protected $table_prefix;
036
037 /** @var string */
038 protected $phpbb_root_path;
039
040 /** @var string */
041 protected $php_ext;
042
043 /** @var array Errors, if any occurred */
044 protected $errors;
045
046 /** @var array List of queries executed through $this->sql_query() */
047 protected $queries = array();
048
049 /**
050 * Constructor
051 *
052 * @param \phpbb\config\config $config
053 * @param \phpbb\db\driver\driver_interface $db
054 * @param \phpbb\db\tools\tools_interface $db_tools
055 * @param string $phpbb_root_path
056 * @param string $php_ext
057 * @param string $table_prefix
058 */
059 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)
060 {
061 $this->config = $config;
062 $this->db = $db;
063 $this->db_tools = $db_tools;
064 $this->table_prefix = $table_prefix;
065
066 $this->phpbb_root_path = $phpbb_root_path;
067 $this->php_ext = $php_ext;
068
069 $this->errors = array();
070 }
071
072 /**
073 * {@inheritdoc}
074 */
075 static public function depends_on()
076 {
077 return array();
078 }
079
080 /**
081 * {@inheritdoc}
082 */
083 public function effectively_installed()
084 {
085 return false;
086 }
087
088 /**
089 * {@inheritdoc}
090 */
091 public function update_schema()
092 {
093 return array();
094 }
095
096 /**
097 * {@inheritdoc}
098 */
099 public function revert_schema()
100 {
101 return array();
102 }
103
104 /**
105 * {@inheritdoc}
106 */
107 public function update_data()
108 {
109 return array();
110 }
111
112 /**
113 * {@inheritdoc}
114 */
115 public function revert_data()
116 {
117 return array();
118 }
119
120 /**
121 * Wrapper for running queries to generate user feedback on updates
122 *
123 * @param string $sql SQL query to run on the database
124 * @return mixed Query result from db->sql_query()
125 */
126 protected function sql_query($sql)
127 {
128 $this->queries[] = $sql;
129
130 $this->db->sql_return_on_error(true);
131
132 if ($sql === 'begin')
133 {
134 $result = $this->db->sql_transaction('begin');
135 }
136 else if ($sql === 'commit')
137 {
138 $result = $this->db->sql_transaction('commit');
139 }
140 else
141 {
142 $result = $this->db->sql_query($sql);
143 if ($this->db->get_sql_error_triggered())
144 {
145 $this->errors[] = array(
146 'sql' => $this->db->get_sql_error_sql(),
147 'code' => $this->db->get_sql_error_returned(),
148 );
149 }
150 }
151
152 $this->db->sql_return_on_error(false);
153
154 return $result;
155 }
156
157 /**
158 * Get the list of queries run
159 *
160 * @return array
161 */
162 public function get_queries()
163 {
164 return $this->queries;
165 }
166 }
167