3 * Base interface for all DBMS-specific code.
10 * Base interface for all DBMS-specific code. At a bare minimum, all of the
11 * following must be implemented to support MediaWiki
15 interface DatabaseType
{
18 * Get the type of the DBMS, as it appears in $wgDBtype.
22 public function getType();
25 * Open a connection to the database. Usually aborts on failure
26 * If the failFunction is set to a non-zero integer, returns success
28 * @param $server String: database server host
29 * @param $user String: database user name
30 * @param $password String: database user password
31 * @param $dbName String: database name
33 * @throws DBConnectionError
35 public function open( $server, $user, $password, $dbName );
38 * The DBMS-dependent part of query()
39 * @todo @fixme Make this private someday
41 * @param $sql String: SQL query.
42 * @return Result object to feed to fetchObject, fetchRow, ...; or false on failure
45 /*private*/ function doQuery( $sql );
48 * Fetch the next row from the given result object, in object form.
49 * Fields can be retrieved with $row->fieldname, with fields acting like
52 * @param $res SQL result object as returned from DatabaseBase::query(), etc.
54 * @throws DBUnexpectedError Thrown if the database returns an error
56 public function fetchObject( $res );
59 * Fetch the next row from the given result object, in associative array
60 * form. Fields are retrieved with $row['fieldname'].
62 * @param $res SQL result object as returned from DatabaseBase::query(), etc.
64 * @throws DBUnexpectedError Thrown if the database returns an error
66 public function fetchRow( $res );
69 * Get the number of rows in a result object
71 * @param $res Mixed: A SQL result
74 public function numRows( $res );
77 * Get the number of fields in a result object
78 * @see http://www.php.net/mysql_num_fields
80 * @param $res Mixed: A SQL result
83 public function numFields( $res );
86 * Get a field name in a result object
87 * @see http://www.php.net/mysql_field_name
89 * @param $res Mixed: A SQL result
93 public function fieldName( $res, $n );
96 * Get the inserted value of an auto-increment row
98 * The value inserted should be fetched from nextSequenceValue()
101 * $id = $dbw->nextSequenceValue('page_page_id_seq');
102 * $dbw->insert('page',array('page_id' => $id));
103 * $id = $dbw->insertId();
107 public function insertId();
110 * Change the position of the cursor in a result object
111 * @see http://www.php.net/mysql_data_seek
113 * @param $res Mixed: A SQL result
114 * @param $row Mixed: Either MySQL row or ResultWrapper
116 public function dataSeek( $res, $row );
119 * Get the last error number
120 * @see http://www.php.net/mysql_errno
124 public function lastErrno();
127 * Get a description of the last error
128 * @see http://www.php.net/mysql_error
132 public function lastError();
135 * mysql_fetch_field() wrapper
136 * Returns false if the field doesn't exist
138 * @param $table string: table name
139 * @param $field string: field name
141 public function fieldInfo( $table, $field );
144 * Get the number of rows affected by the last write query
145 * @see http://www.php.net/mysql_affected_rows
149 public function affectedRows();
152 * Wrapper for addslashes()
154 * @param $s string: to be slashed.
155 * @return string: slashed string.
157 public function strencode( $s );
160 * Returns a wikitext link to the DB's website, e.g.,
161 * return "[http://www.mysql.com/ MySQL]";
162 * Should at least contain plain text, if for some reason
163 * your database has no website.
165 * @return string: wikitext of a link to the server software's web site
167 public static function getSoftwareLink();
170 * A string describing the current software version, like from
171 * mysql_get_server_info(). Will be listed on Special:Version, etc.
173 * @return string: Version information from the database
175 public function getServerVersion();