本文整理汇总了PHP中Vars::findByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Vars::findByName方法的具体用法?PHP Vars::findByName怎么用?PHP Vars::findByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vars
的用法示例。
在下文中一共展示了Vars::findByName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trim
// prod protection for cc all
if ($command == 'cc' && $arg1 == 'all' && ENV == 'prod') {
echo "*********************************************************************\n";
echo " !!! This site is now under PROD mode. ARE YOU SURE TO CLEAR ALL !!! \n";
echo "*********************************************************************\n";
echo "yes/no\n";
$confirmation = trim(fgets(STDIN));
if ($confirmation !== 'yes') {
echo "abort...\n";
exit(0);
}
}
//-- Clear cache
if ($command == 'cc') {
if (Vars::tableExist() && ($var = Vars::findByName('system'))) {
$var->delete();
echo " - System var cache has been cleared.\n";
}
if ($arg1 == 'all') {
echo " - Drop table 'vars' ";
echo Vars::dropTable() ? "success\n" : "fail\n";
echo " - Drop table 'user' ";
echo User::dropTable() ? "success\n" : "fail\n";
}
}
//-- Import DB
if ($command == 'import' && $arg1 == 'db' && (is_null($arg2) || $arg2 == 'core')) {
echo " - Create table 'vars' ";
echo Vars::createTableIfNotExist() ? "success\n" : "fail\n";
echo " - Create table 'user' ";
示例2: is_maintenance
/**
* check if maintenance mode is on
*/
function is_maintenance()
{
$var = Vars::findByName('maintenance');
if ($var && $var->getValue() == 1) {
return true;
}
return false;
}
示例3: isset
<?php
$maintenance = Vars::findByName('maintenance');
$maintenance = $maintenance ? $maintenance->getValue() : 0;
// handle form submission
if (isset($_POST['submit'])) {
$switch = isset($_POST['switch']) && $_POST['switch'] == 1 ? 1 : 0;
$var = new Vars();
$var->setName('maintenance');
$var->setValue($switch);
$var->save();
Message::register(new Message(Message::SUCCESS, i18n(array('en' => 'Maintenance mode updated', 'zh' => '系统维护模式已更新'))));
HTML::forward('admin/maintenance');
exit;
}
// presentation
$html = new HTML();
$html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'Maintenance mode', 'zh' => '系统维护设置'))), true);
$html->output('<div id="wrapper">');
$html->renderOut('core/backend/header');
$html->renderOut('core/backend/maintenance', array('maintenance' => $maintenance));
$html->output('</div>');
$html->renderOut('core/backend/html_footer');
exit;