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


PHP AttributeValue::model方法代码示例

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


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

示例1: getTeacherAttributeValue

 public static function getTeacherAttributeValue($teacher, $attribute){
     $result = '';
     switch($attribute){
         case '1': //capacity
             $result = AttributeValue::model()->findByAttributes(array('teacher'=>$teacher, 'attribute'=>$attribute))->value;
             break;
         case '2': //trainer's students
             $result = TeacherHelper::getTrainerStudents($teacher);
             break;
         case '3': //consultant_modules
             $result = TeacherHelper::getConsultantModules($teacher);
             break;
         case '4':// leader's projects
             $result = TeacherHelper::getLeaderProjects($teacher);
             break;
         case '6'://leader's modules
             $result = TeacherHelper::getLeaderModules($teacher);
             break;
         case '7'://author's modules
             $result = TeacherHelper::getLeaderModules($teacher);
             break;
         case '8'://leader's capacity
             $result = AttributeValue::model()->findByAttributes(array('teacher'=>$teacher, 'attribute'=>$attribute))->value;
             break;
         default:
             $result = AttributeValue::model()->findByAttributes(array('teacher'=>$teacher, 'attribute'=>$attribute))->value;
     }
     return $result;
 }
开发者ID:nico13051995,项目名称:IntITA,代码行数:29,代码来源:TeacherHelper.php

示例2: actionDeleteFile

 public function actionDeleteFile()
 {
     if (!Yii::app()->getRequest()->getIsPostRequest()) {
         throw new CHttpException();
     }
     $product = (int) Yii::app()->getRequest()->getPost('product');
     $attribute = (int) Yii::app()->getRequest()->getPost('attribute');
     $model = AttributeValue::model()->find('product_id = :product AND attribute_id = :attribute', [':product' => $product, ':attribute' => $attribute]);
     if (null === $model || null === $model->getFilePath()) {
         Yii::app()->ajax->success();
     }
     $model->delete();
     Yii::app()->ajax->success();
 }
开发者ID:yupe,项目名称:yupe,代码行数:14,代码来源:AttributeBackendController.php

示例3: uploadAttributesFiles

 /**
  * @param $model
  */
 protected function uploadAttributesFiles($model)
 {
     if (!empty($_FILES['Attribute']['name'])) {
         foreach ($_FILES['Attribute']['name'] as $key => $file) {
             $value = AttributeValue::model()->find('product_id = :product AND attribute_id = :attribute', [':product' => $model->id, ':attribute' => $key]);
             $value = $value ?: new AttributeValue();
             $value->setAttributes(['product_id' => $model->id, 'attribute_id' => $key]);
             $value->addFileInstanceName('Attribute[' . $key . '][name]');
             if (false === $value->save()) {
                 Yii::app()->getUser()->setFlash(\yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('StoreModule.store', 'Error uploading some files...'));
             }
         }
     }
 }
开发者ID:syrexby,项目名称:domovoishop.by,代码行数:17,代码来源:ProductBackendController.php

示例4: saveTypeAttributes

 /**
  * @param array $attributes
  * @return bool
  */
 public function saveTypeAttributes(array $attributes)
 {
     $transaction = Yii::app()->getDb()->beginTransaction();
     try {
         foreach ($attributes as $attribute => $value) {
             if (null === $value) {
                 continue;
             }
             $model = AttributeValue::model()->find('product_id = :product AND attribute_id = :attribute', [':product' => $this->id, ':attribute' => $attribute]);
             //множественные значения
             if (is_array($value)) {
                 AttributeValue::model()->deleteAll('product_id = :product AND attribute_id = :attribute', [':product' => $this->id, ':attribute' => $attribute]);
                 foreach ($value as $val) {
                     $model = new AttributeValue();
                     if (false === $model->store($attribute, $val, $this)) {
                         throw new InvalidArgumentException('Error store attribute!');
                     }
                 }
             } else {
                 $model = $model ?: new AttributeValue();
                 if (false === $model->store($attribute, $value, $this)) {
                     throw new InvalidArgumentException('Error store attribute!');
                 }
             }
         }
         $transaction->commit();
         return true;
     } catch (Exception $e) {
         $transaction->rollback();
         return false;
     }
 }
开发者ID:yupe,项目名称:yupe,代码行数:36,代码来源:Product.php

示例5: attribute

 /**
  * @param $attribute
  * @param null $default
  * @return bool|float|int|null|string
  */
 public function attribute($attribute, $default = null)
 {
     if ($this->getIsNewRecord()) {
         return null;
     }
     //@TODO переделать на получение в 1 запрос
     $model = AttributeValue::model()->with('attribute')->find('product_id = :product AND attribute_id = :attribute', [':product' => $this->id, ':attribute' => $attribute->id]);
     if (null === $model) {
         return null;
     }
     return $model->value($default);
 }
开发者ID:alextravin,项目名称:yupe,代码行数:17,代码来源:Product.php


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