public static function SetProperty($sName, $sValue, $sComment = '', $sDescription = null) { try { $oSearch = DBObjectSearch::FromOQL('SELECT DBProperty WHERE name = :name'); $oSet = new DBObjectSet($oSearch, array(), array('name' => $sName)); if ($oSet->Count() == 0) { $oProp = new DBProperty(); $oProp->Set('name', $sName); $oProp->Set('description', $sDescription); $oProp->Set('value', $sValue); $oProp->Set('change_date', time()); $oProp->Set('change_comment', $sComment); $oProp->DBInsert(); } elseif ($oSet->Count() == 1) { $oProp = $oSet->fetch(); if (!is_null($sDescription)) { $oProp->Set('description', $sDescription); } $oProp->Set('value', $sValue); $oProp->Set('change_date', time()); $oProp->Set('change_comment', $sComment); $oProp->DBUpdate(); } else { // Houston... throw new CoreException('duplicate db property'); } } catch (MySQLException $e) { // This might be because the table could not be found, // let's check it and discard silently if this is really the case if (self::IsInstalled()) { throw $e; } IssueLog::Error('Attempting to write a DBProperty while the module has not been installed'); } }
protected function DoExecute() { $sName = 'test'; DBProperty::SetProperty($sName, 'unix time:' . time(), 'means nothing', 'done with the automated test utility'); $sValue = DBProperty::GetProperty($sName, 'defaults to this because the table has not been created (1.0.1 install?)'); echo "<p>Write... then read property <b>{$sName}</b>, found: '{$sValue}'</p>\n"; }