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


PHP Customers::findOne方法代码示例

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


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

示例1: actionIndex

 public function actionIndex()
 {
     if (Helper::checkRoute('index')) {
         $searchModel = new ProvinceSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         if (Yii::$app->request->post('hasEditable')) {
             $ID = \Yii::$app->request->post('editableKey');
             $model = Customers::findOne($ID);
             $out = Json::encode(['output' => '', 'message' => '']);
             // fetch the first entry in posted data (there should
             // only be one entry anyway in this array for an
             // editable submission)
             // - $posted is the posted data for Book without any indexes
             // - $post is the converted array for single model validation
             $post = [];
             $posted = current($_POST['Customers']);
             $post['Customers'] = $posted;
             // load model like any single model validation
             if ($model->load($post)) {
                 // can save model or do something before saving model
                 $model->save();
                 // custom output to return to be displayed as the editable grid cell
                 // data. Normally this is empty - whereby whatever value is edited by
                 // in the input by user is updated automatically.
                 $output = '';
                 // specific use case where you need to validate a specific
                 // editable column posted when you have more than one
                 // EditableColumn in the grid view. We evaluate here a
                 // check to see if buy_amount was posted for the Book model
                 if (isset($posted['CUST_KD_ALIAS'])) {
                     // $output =  Yii::$app->formatter->asDecimal($model->EMP_NM, 2);
                     $output = $model->CUST_KD_ALIAS;
                 }
                 // similarly you can check if the name attribute was posted as well
                 // if (isset($posted['name'])) {
                 //   $output =  ''; // process as you need
                 // }
                 $out = Json::encode(['output' => $output, 'message' => '']);
                 // return ajax json encoded response and exit
                 echo $out;
                 return;
             }
         }
         return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     } else {
         Yii::$app->user->logout();
         $this->redirect(array('/site/login'));
         //
     }
 }
开发者ID:adem-team,项目名称:advanced,代码行数:50,代码来源:ProvinsiCustomersCrmController.php

示例2: findModelcust

 protected function findModelcust($id)
 {
     if (($model = Customers::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:adem-team,项目名称:advanced,代码行数:8,代码来源:KategoriCustomersCrmController.php


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