3 * Database configuration class
5 * Copyright © 2011 Chad Horohoe <chadh@wikimedia.org>
6 * http://www.mediawiki.org/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
26 class DatabaseConf
extends Conf
{
28 * @see Conf::initChangedSettings()
30 protected function initChangedSettings() {
31 $res = wfGetDB( DB_MASTER
)->select( 'config', '*', array(), __METHOD__
);
32 foreach( $res as $row ) {
33 $this->values
[$row->cf_name
] = unserialize( $row->cf_value
);
38 * @see Conf::writeSetting()
45 protected function writeSetting( $name, $value ) {
46 $dbw = wfGetDB( DB_MASTER
);
47 $value = serialize( $value );
48 if( $dbw->selectRow( 'config', 'cf_name', array( 'cf_name' => $name ), __METHOD__
) ) {
49 $dbw->update( 'config', array( 'cf_value' => $value ),
50 array( 'cf_name' => $name ), __METHOD__
);
52 $dbw->insert( 'config',
53 array( 'cf_name' => $name, 'cf_value' => $value ), __METHOD__
);
55 return (bool)$dbw->affectedRows();