本文整理汇总了PHP中Command::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::save方法的具体用法?PHP Command::save怎么用?PHP Command::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Command
的用法示例。
在下文中一共展示了Command::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate($sv = false)
{
if (!Yii::app()->user->isSuperuser() && !Yii::app()->user->can($sv, 'manage commands', true)) {
Yii::app()->user->deny();
}
$model = new Command();
$model->server_id = $sv;
if (isset($_POST['Command'])) {
if (Yii::app()->user->isSuperuser()) {
$model->scenario = 'superuser';
}
$model->attributes = $_POST['Command'];
if ($model->save()) {
Yii::log('Created command ' . $model->id);
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('view', array('model' => $model, 'sv' => $sv, 'edit' => true));
}
示例2: createDefaultCommands
public function createDefaultCommands()
{
$cmds = array(array(Yii::t('mc', 'Message of the Day'), 10, 'motd', ''), array(Yii::t('mc', 'Give Item'), 30, 'give', 'builtin:give'), array(Yii::t('mc', 'Teleport To'), 30, 'tp', 'builtin:tp'), array(Yii::t('mc', 'Summon Player'), 30, 'summon', 'builtin:summon'), array(Yii::t('mc', 'Admin Say'), 30, 'asay', 'builtin:asay'), array(Yii::t('mc', 'Save World'), 30, 'save', 'builtin:save'), array(Yii::t('mc', 'Time'), 10, 'time', 'builtin:time'), array(Yii::t('mc', 'Date'), 10, 'date', 'builtin:date'), array(Yii::t('mc', 'Player List'), 10, 'list', 'builtin:list'), array(Yii::t('mc', 'Say Player List'), 30, 'saylist', 'builtin:saylist'), array(Yii::t('mc', 'Create Backup'), 40, '', 'builtin:backup'), array(Yii::t('mc', 'Restart'), 40, '', 'builtin:restart'), array(Yii::t('mc', 'Restart if Empty'), 40, '', 'builtin:restart_empty'), array(Yii::t('mc', 'Stop'), 40, '', 'builtin:stop'), array(Yii::t('mc', 'Stop if Empty'), 40, '', 'builtin:stop_empty'), array(Yii::t('mc', 'Start'), 40, '', 'builtin:start'), array(Yii::t('mc', 'Teleport Other'), 40, '', 'builtin:tp_other'));
foreach ($cmds as $c) {
$cmd = Command::model()->findByAttributes(array('server_id' => $this->id, 'name' => $c[0]));
if ($cmd) {
continue;
}
$cmd = new Command();
$cmd->server_id = $this->id;
$cmd->name = $c[0];
$cmd->level = $c[1];
$cmd->chat = $c[2];
$cmd->run = $c[3];
$cmd->save();
}
}