本文整理汇总了PHP中Option::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::model方法的具体用法?PHP Option::model怎么用?PHP Option::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::model方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public static function get($key)
{
$option = Option::model()->find('`key`=:key', array(':key' => $key));
if ($option) {
return $option->value;
} else {
exit("Error: Option {$option->key} not found!");
}
}
示例2: set2Db
/**
* 更新Option的值
*/
private function set2Db($key, $value)
{
$item = Option::model()->find("option_name=:option_name", array("option_name" => $key));
if (!isset($item)) {
$item = new Option();
$item->option_name = $key;
}
$item->option_value = $value;
$item->save();
return $item;
}
示例3: save
public function save($data)
{
foreach ($data as $key => $value) {
$option = Option::model()->find('`key`=:key', array(':key' => $key));
if ($option) {
$option->value = $value;
$option->save();
} else {
exit("Error: Option {$option->key} not found!");
}
}
return true;
}
示例4: foreach
<?php
if (!empty($options)) {
?>
<div class="row-fluid options-order">
<div class="span12">
<?php
echo Yii::t('label', 'Select Options');
foreach ($options as $i => $noption) {
$option = Option::model()->findByPk($noption[0]->option_id);
$productoption = $noption[0];
$productoptionvalue = $noption[1];
$required = array();
if ($productoption->required) {
$required = array('required' => true);
}
?>
<div class="row-fluid">
<?php
echo CHtml::hiddenField("OrderOption[{$i}][name]", $option->getName());
echo CHtml::hiddenField("OrderOption[{$i}][product_option_id]", $productoption->id);
echo CHtml::hiddenField("OrderOption[{$i}][order_product_id]", $productoption->product_id);
echo CHtml::hiddenField("OrderOption[{$i}][type]", $option->type);
?>
<div class="">
<?php
echo CHtml::label($option->getName(), $option->getName(), $required);
?>
</div>
<?php
if ($option->type == 'select' || $option->type == 'radio' || $option->type == 'checkbox') {
示例5: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Option the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Option::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例6: actionIndex
public function actionIndex()
{
$options = Option::model()->findAll();
$this->render('index', array('options' => $options));
}
示例7: array
<div class="row">
<span class="span2">
<?php
$this->widget('yiiwheels.widgets.select2.WhSelect2', array('asDropDownList' => true, 'name' => 'optvalsearch', 'model' => new Option(), 'attribute' => 'name', 'htmlOptions' => array('id' => 'optSelect'), 'data' => TbHtml::listData(Option::model()->findAll(), 'id', function ($data) {
return $data->getName();
}), 'pluginOptions' => array('placeholder' => 'Enter Option', 'width' => '100%')));
?>
</span>
<span class="span2"><?php
echo TbHtml::button(Yii::t('label', 'Add Option'), array('class' => 'add-opt', 'color' => TbHtml::BUTTON_COLOR_PRIMARY));
?>
</span>
</div>
<div id="copyGrid" class="row hide">
<?php
$this->widget('bootstrap.widgets.TbGridView', array('type' => array(TbHtml::GRID_TYPE_STRIPED, TbHtml::GRID_TYPE_BORDERED, TbHtml::GRID_TYPE_CONDENSED), 'dataProvider' => new CArrayDataProvider(array()), 'columns' => array('id', array('name' => 'option_value_id', 'header' => Yii::t('label', 'Option Value')), array('name' => 'quantity', 'header' => Yii::t('label', 'Quantity')), array('name' => 'subtract', 'header' => Yii::t('label', 'Subtract')), array('name' => 'price_prefix', 'header' => Yii::t('label', 'Price Operator')), array('name' => 'price', 'header' => Yii::t('label', 'Price')), array('name' => 'weight_prefix', 'header' => Yii::t('label', 'Weight Operator')), array('name' => 'weight', 'header' => Yii::t('label', 'Weight')), array('class' => 'bootstrap.widgets.TbButtonColumn', 'htmlOptions' => array('style' => 'width: 20px'), 'buttons' => array('delete' => array('label' => Yii::t('label', 'Delete'), 'options' => array("class" => "doptval", 'title' => Yii::t('label', 'Delete')))), 'template' => ' {delete}'))));
?>
<div class="row"><span class="span2 offset7"><?php
echo TbHtml::button(Yii::t('label', 'Add Option Value'), array('class' => 'add-opval', 'color' => TbHtml::BUTTON_COLOR_PRIMARY));
?>
</span></div>
</div>
<div class="row optiontype hide"><?php
echo TbHtml::dropDownList('option_type', '', TbHtml::listData(Option::model()->findAll(), 'id', 'type'), array('id' => 'option_type_list'));
?>
</div>
<?php
$this->endWidget();
?>
<br/>
<br/>
示例8: actionSort
public function actionSort()
{
if (isset($_POST['items']) && is_array($_POST['items'])) {
$i = 0;
foreach ($_POST['items'] as $item) {
$project = Option::model()->findByPk($item);
$project->sort_order = $i;
$project->save();
$i++;
}
}
}
示例9: getMID
/**
* 获取版本MID
* 升级请求增量包时我们需要MID,但是在二级目录下,通过params['app']['mid']获取的mid会产生混乱
* 故用一下方法去获取MID
* @return string $mid
*/
public static function getMID()
{
$mid = "6c646b6e64676c63";
$option = Option::model()->find("option_name='mid'");
if (empty($option)) {
return $mid;
}
return $option['option_value'];
}