本文整理汇总了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;
}
示例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, '该商品订单已满');
}
}
}
示例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]);
}