本文整理汇总了PHP中Options::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Options::exists方法的具体用法?PHP Options::exists怎么用?PHP Options::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Options
的用法示例。
在下文中一共展示了Options::exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date
}
if (isset($_POST[$dateOption . $dmy[1]])) {
$mm = $_POST[$dateOption . $dmy[1]];
} else {
$mm = 1;
}
if (isset($_POST[$dateOption . $dmy[2]])) {
$yyyy = $_POST[$dateOption . $dmy[2]];
} else {
$yyyy = date('Y', time());
}
//echo $dd . "/" . $mm . "/" . $yyyy;
$timestamp = mktime(0, 0, 0, $mm, $dd, $yyyy);
//echo date('r', $timestamp);
// Check if the options exists, then if the value compares otherwise update it.
if (Options::exists($dateOption)) {
// Compare the posted value to the value in the DB and update it if neccesarry
if (htmlspecialchars(Options::get($dateOption)) !== htmlspecialchars($timestamp)) {
// Set the option to the new value
Options::set($dateOption, $timestamp);
$changes = true;
}
}
}
if (isset($_POST['action']) && $_POST['action'] == 'update') {
Options::set($_POST['option'], Options::get($_POST['option']), $_POST['type'], $_POST['group']);
$changes = true;
}
if (isset($_POST['action']) && $_POST['action'] == 'add') {
Options::set($_POST['option_name'], $_POST['option_value'], $_POST['type'], $_POST['group']);
$changes = true;
示例2: add
public static function add($option, $value = '', $type = false, $group = false)
{
$db = Database::getDatabase();
/*if ($value == '') $value = Options::value($option);*/
if ($type == false) {
$type = Options::type($option);
}
if ($group == false) {
$group = Options::group($option);
}
if (Options::exists($option)) {
$db->query('UPDATE
options
SET
`value`=:value:, `type`=:type:, `group`=:group:
WHERE
`key`=:key:', array('key' => $option, 'value' => $value, 'type' => $type, 'group' => $group));
/*echo "Update option";*/
} else {
$db->query('INSERT INTO
options
(`key`, `value`, `type`, `group`)
VALUES
(:key:, :value:, :type:, :group:)', array('key' => $option, 'value' => $value, 'type' => $type, 'group' => $group));
/*echo "Inserted new option";*/
}
return $db->affectedRows();
}