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