Merge "Add Parsoid-specific tests for link trail and -prefix escaping"
[mediawiki.git] / includes / db / IORMRow.php
blobf8833f5f671077dfcf7d3f6c23db619741f1e71a
1 <?php
2 /**
3 * Interface for representing objects that are stored in some DB table.
4 * This is basically an ORM-like wrapper around rows in database tables that
5 * aims to be both simple and very flexible. It is centered around an associative
6 * array of fields and various methods to do common interaction with the database.
8 * Documentation inline and at https://www.mediawiki.org/wiki/Manual:ORMTable
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * http://www.gnu.org/copyleft/gpl.html
25 * @since 1.20
27 * @file
28 * @ingroup ORM
30 * @license GNU GPL v2 or later
31 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
34 interface IORMRow {
36 /**
37 * Load the specified fields from the database.
39 * @since 1.20
40 * @deprecated since 1.21
42 * @param array|null $fields
43 * @param boolean $override
44 * @param boolean $skipLoaded
46 * @return bool Success indicator
48 public function loadFields( $fields = null, $override = true, $skipLoaded = false );
50 /**
51 * Gets the value of a field.
53 * @since 1.20
55 * @param string $name
56 * @param mixed $default
58 * @throws MWException
59 * @return mixed
61 public function getField( $name, $default = null );
63 /**
64 * Gets the value of a field but first loads it if not done so already.
66 * @since 1.20
67 * @deprecated since 1.21
69 * @param string$name
71 * @return mixed
73 public function loadAndGetField( $name );
75 /**
76 * Remove a field.
78 * @since 1.20
80 * @param string $name
82 public function removeField( $name );
84 /**
85 * Returns the objects database id.
87 * @since 1.20
89 * @return integer|null
91 public function getId();
93 /**
94 * Sets the objects database id.
96 * @since 1.20
98 * @param integer|null $id
100 public function setId( $id );
103 * Gets if a certain field is set.
105 * @since 1.20
107 * @param string $name
109 * @return boolean
111 public function hasField( $name );
114 * Gets if the id field is set.
116 * @since 1.20
118 * @return boolean
120 public function hasIdField();
123 * Sets multiple fields.
125 * @since 1.20
127 * @param array $fields The fields to set
128 * @param boolean $override Override already set fields with the provided values?
130 public function setFields( array $fields, $override = true );
133 * Serializes the object to an associative array which
134 * can then easily be converted into JSON or similar.
136 * @since 1.20
138 * @param null|array $fields
139 * @param boolean $incNullId
141 * @return array
143 public function toArray( $fields = null, $incNullId = false );
146 * Load the default values, via getDefaults.
148 * @since 1.20
149 * @deprecated since 1.21
151 * @param boolean $override
153 public function loadDefaults( $override = true );
156 * Writes the answer to the database, either updating it
157 * when it already exists, or inserting it when it doesn't.
159 * @since 1.20
161 * @param string|null $functionName
162 * @deprecated since 1.21
164 * @return boolean Success indicator
166 public function save( $functionName = null );
169 * Removes the object from the database.
171 * @since 1.20
172 * @deprecated since 1.21
174 * @return boolean Success indicator
176 public function remove();
179 * Return the names and values of the fields.
181 * @since 1.20
183 * @return array
185 public function getFields();
188 * Return the names of the fields.
190 * @since 1.20
192 * @return array
194 public function getSetFieldNames();
197 * Sets the value of a field.
198 * Strings can be provided for other types,
199 * so this method can be called from unserialization handlers.
201 * @since 1.20
203 * @param string $name
204 * @param mixed $value
206 * @throws MWException
208 public function setField( $name, $value );
211 * Add an amount (can be negative) to the specified field (needs to be numeric).
213 * @since 1.20
214 * @deprecated since 1.21
216 * @param string $field
217 * @param integer $amount
219 * @return boolean Success indicator
221 public function addToField( $field, $amount );
224 * Return the names of the fields.
226 * @since 1.20
228 * @return array
230 public function getFieldNames();
233 * Computes and updates the values of the summary fields.
235 * @since 1.20
236 * @deprecated since 1.21
238 * @param array|string|null $summaryFields
240 public function loadSummaryFields( $summaryFields = null );
243 * Sets the value for the @see $updateSummaries field.
245 * @since 1.20
246 * @deprecated since 1.21
248 * @param boolean $update
250 public function setUpdateSummaries( $update );
253 * Sets the value for the @see $inSummaryMode field.
255 * @since 1.20
256 * @deprecated since 1.21
258 * @param boolean $summaryMode
260 public function setSummaryMode( $summaryMode );
263 * Returns the table this IORMRow is a row in.
265 * @since 1.20
266 * @deprecated since 1.21
268 * @return IORMTable
270 public function getTable();