本文整理匯總了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();
}