当前位置: 首页>>代码示例>>PHP>>正文


PHP Value::getPrimaryKey方法代码示例

本文整理汇总了PHP中Value::getPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Value::getPrimaryKey方法的具体用法?PHP Value::getPrimaryKey怎么用?PHP Value::getPrimaryKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Value的用法示例。


在下文中一共展示了Value::getPrimaryKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionUpdate

    public function actionUpdate($id)
    {
        $model = $this->loadModel($id);
        if (isset($_POST['deleteValID'])) {
            Value::model()->deleteAll('value_id=' . $_POST['deleteValID']);
            ValueDescription::model()->deleteAll('value_id=' . $_POST['deleteValID']);
            Attribute2value::model()->deleteAll('value_id=' . $_POST['deleteValID']);
            echo 'success';
            exit;
        }
        $lang_model = new LanguageModel;
        $AttrDescModel = new AttributeDescription;
        $Attribute2value = $this->loadAttrToValModel('attribute_id=' . $id);

        $ValueModel = new Value;
        $ValueDescription = new ValueDescription;

        $aLangNames = array();
        $aValNames = array();
        // Uncomment the following line if AJAX validation is needed
        // $this->performAjaxValidation($model);

        $allLangs = $lang_model->findAll('1', array('order' => 'id ASC'));
        $allLangsJS = array();
        $aValuesNames = array();
        foreach ($allLangs as $language) {
          $allLangsJS[$language['id']] = $language['code'];

          foreach ($Attribute2value as $record) {
            $aNames = $ValueDescription->find('language_id=' . $language['id'] . ' AND value_id=' . $record['value_id']);
            $aValuesNames[$record['value_id']][$language['code']]['value_id'] = $record['value_id'];
            $aValuesNames[$record['value_id']][$language['code']]['value_name'] = $aNames['value_name'];
            $aValuesNames[$record['value_id']][$language['code']]['language_id'] = $language['id'];
          }
        }

        $aAttrNames = $AttrDescModel->findAll("attribute_id = '" . $id . "'");
        foreach ($aAttrNames as $lng_attribute) {
            $aLangNames[$lng_attribute['language_id']] = $lng_attribute['attribute_name'];
        }

        if (isset($_POST['Attribute'])) {
            $model->attributes = $_POST['Attribute'];
            $model->updateByPk($id, $model->attributes);
            if (isset($_POST['AttributeDescription']['attribute_name'])) {
                foreach ($_POST['AttributeDescription']['attribute_name'] as $langId => $attrName) {
                    $attr_desc_model = new AttributeDescription;
                    $attr_desc_model->updateByPk(array('attribute_id' => $id, 'language_id' => $langId), array('attribute_name' => $attrName));
                }
            }

            if (isset($_POST['NewAttrValue'])) {
                foreach ($_POST['NewAttrValue'] as $spec_id => $new_val) {
                    $ValueModel = new Value;
                    $ValueModel->attributes = array(
                        'status' => 1,
                    );
                    $ValueModel->save();
                    $v_id = $ValueModel->getPrimaryKey();

                    foreach ($new_val as $lang_id => $value) {
                        if ($value != '') {
                            $ValueDescription = new ValueDescription;
                            $ValueDescription->attributes = array(
                                'value_id' => $v_id,
                                'language_id' => $lang_id,
                                'value_name' => $value,
                            );
                            $ValueDescription->save();
                        }
                    }

                    $Attribute2value = new Attribute2value;
                    $Attribute2value->attributes = array('attribute_id' => $id, 'value_id' => $v_id);
                    $Attribute2value->save();
                }
            }
            if (isset($_POST['ValueDescription']['value_name'])) {
                foreach ($_POST['ValueDescription']['value_name'] as $language_id => $lang_values) {
                    foreach ($lang_values as $value_id => $value_name) {
                        $value_desc_model = new ValueDescription;
                        $value_desc_model->updateByPk(array('value_id' => $value_id, 'language_id' => $language_id), array('value_name' => $value_name));
                    }
                }

            }
            $this->redirect(array('index'));
        }

        $this->render('update', array(
            'model' => $model,
            'allLangs' => $allLangs,
            'AttrDescModel' => $AttrDescModel,
            'aLangNames' => $aLangNames,
            'allLangsJS' => json_encode($allLangsJS),
            'aValuesNames' => $aValuesNames,
            'ValueDescription' => $ValueDescription,
        ));
    }
开发者ID:Kostiantin,项目名称:floors,代码行数:99,代码来源:AttributeController.php


注:本文中的Value::getPrimaryKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。