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


PHP Order::tableName方法代码示例

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


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

示例1: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Client::find()->select("CONCAT_WS(' ',`surname`,clients.`name`) as name,phone,address, sum(cost*count) as cost,clients.id as id")->leftJoin(Order::tableName(), Order::tableName() . '.id_client=' . Client::tableName() . '.id')->groupBy('id_client');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['name' => $this->name, 'surname' => $this->surname, 'phone' => $this->phone, 'address' => $this->address]);
     return $dataProvider;
 }
开发者ID:earlcherry,项目名称:test-project,代码行数:20,代码来源:OrderSearch.php

示例2: validateCommodity

 public function validateCommodity($attribute, $params)
 {
     echo 'validateCommodity';
     $commodity = Commodity::find()->where('commodity_id = :commodity_id', [':commodity_id' => $this->{$attribute}])->one();
     if (is_null($commodity)) {
         return $this->addError($attribute, '商品不存在');
     }
     if ($this->scenario == 'create') {
         $orderCount = (new Query())->from(Order::tableName())->where('commodity = :commodity', [':commodity' => $this->{$attribute}])->count();
         $coCount = (new Query())->select(CommodityOrderDetail::tableName() . '.num as num')->from(CommodityOrder::tableName())->leftJoin(CommodityOrderDetail::tableName(), CommodityOrderDetail::tableName() . '.coid = ' . CommodityOrder::tableName() . '.id')->where('commodity_id = :commodity_id', [':commodity_id' => $this->{$attribute}])->sum('num');
         if ($orderCount + 1 == $coCount) {
             $sql = "update " . CommodityOrder::tableName() . " set op_statu = " . CommodityOrder::$_OP_FINISH . " where commodity_id = :commodity_id";
             $db = Yii::$app->db;
             $command = $db->createCommand($sql);
             $command->bindParam(":commodity_id", $this->{$attribute}, PDO::PARAM_STR);
             $command->execute();
         }
         if ($orderCount >= $coCount) {
             return $this->addError($attribute, '该商品订单已满');
         }
     }
 }
开发者ID:vilison,项目名称:yii2-order,代码行数:22,代码来源:Order.php

示例3: actionAudit

 public function actionAudit()
 {
     $model = new OrderSearchForm();
     $model->load(Yii::$app->request->post());
     $query = (new Query())->select('*')->from(Order::tableName())->where('1=1');
     if (!empty($model->buyer)) {
         $query->andWhere('buyer=:buyer', [':buyer' => $model->buyer]);
     }
     if (!empty($model->shop)) {
         $query->andWhere('shop=:shop', [':shop' => $model->shop]);
     }
     if (!empty($model->commodity)) {
         $query->andWhere('commodity_id like :commodity_id', [':commodity_id' => '%' . $model->commodity . '%']);
     }
     if (!empty($model->order_no)) {
         $query->andWhere('order_no=:order_no', [':order_no' => $model->order_no]);
     }
     if (!empty($model->btime)) {
         $query->andWhere('create_time >= :create_time', [':create_time' => $model->btime]);
     }
     if (!empty($model->etime)) {
         $query->andWhere('create_time <= :create_time', [':create_time' => $model->etime]);
     }
     $query->andWhere('statu = 0');
     $query->orderBy('create_time desc');
     $pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => '20']);
     $query->limit($pages->limit)->offset($pages->offset);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]);
     $audit_json = array();
     foreach (Order::$Audits as $key => $value) {
         $enarray = ['value' => $key, 'text' => $value];
         array_push($audit_json, $enarray);
     }
     $audit_json = json_encode($audit_json);
     return $this->render('audit', ['model' => $model, 'dataProvider' => $dataProvider, 'pages' => $pages, 'audit_json' => $audit_json]);
 }
开发者ID:vilison,项目名称:yii2-order,代码行数:36,代码来源:OrderController.php


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