PortableInfobox/includes/services/Helpers/PagePropsProxy.php

43 lines
725 B
PHP
Raw Normal View History

2015-09-23 13:51:41 +00:00
<?php
namespace PortableInfobox\Helpers;
2015-09-23 13:51:41 +00:00
class PagePropsProxy {
public function get( $id, $property ) {
$dbr = wfGetDB( DB_REPLICA );
$propValue = $dbr->selectField(
'page_props',
2018-08-16 09:25:53 +00:00
'pp_value',
[
'pp_page' => $id,
'pp_propname' => $property
2018-08-16 09:25:53 +00:00
],
__METHOD__
);
return $propValue;
2015-09-23 13:51:41 +00:00
}
2018-08-16 09:25:53 +00:00
public function set( $id, array $props ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->startAtomic( __METHOD__ );
2018-08-16 09:25:53 +00:00
foreach ( $props as $sPropName => $sPropValue ) {
$dbw->replace(
"page_props",
2018-08-16 09:25:53 +00:00
[
"pp_page",
"pp_propname"
2018-08-16 09:25:53 +00:00
],
[
"pp_page" => $id,
"pp_propname" => $sPropName,
"pp_value" => $sPropValue
2018-08-16 09:25:53 +00:00
],
__METHOD__
);
}
$dbw->endAtomic( __METHOD__ );
2015-09-23 13:51:41 +00:00
}
}