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


PHP User::tableName方法代码示例

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


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

示例1: actionDelete

 public function actionDelete($seed_id, $reason = "", $penalty = 0)
 {
     if (!is_numeric($penalty) || !is_numeric($seed_id)) {
         return ['result' => 'failed', 'extra' => 'illegal param'];
     }
     $penalty = intval($penalty);
     $seed_id = intval($seed_id);
     /** @var User $user */
     $user = User::findOne(Yii::$app->user->identity->getId());
     if ($user->priv != 'Admin') {
         return ['result' => 'failed', 'extra' => 'permission denied'];
     }
     /** @var Seed $seed */
     $seed = Seed::findOne($seed_id);
     if (empty($seed) || !$seed->is_valid) {
         return ['result' => 'failed', 'extra' => 'not exists'];
     }
     $ret['result'] = 'success';
     $publisher = $seed->publisher;
     $record = new SeedOperationRecord();
     $record->admin_id = $user->user_id;
     $record->publisher_id = $publisher->user_id;
     $record->seed_id = $seed->seed_id;
     $record->operation_type = "DELETE";
     $record->detail_info = json_encode(['penalty' => $penalty, 'reason' => $reason]);
     $record->insert();
     $seed->is_valid = false;
     $seed->save();
     $publisher->stat_up -= intval($penalty) * (1 << 30);
     $publisher->save();
     $tmp = $seed->attributes;
     $tmp['discuz_pub_uid'] = $publisher->discuz_user_id;
     //查询所有下载过这个种子的人
     $res = History::find()->leftJoin(User::tableName(), User::tableName() . '.user_id=' . History::tableName() . ".user_id")->where(['seed_id' => $seed->seed_id])->groupBy([History::tableName() . ".user_id", "history_id"])->all();
     Yii::info($res);
     foreach ($res as $r) {
         $tmp['discuz_use_uid'][] = $r->user->discuz_user_id;
     }
     $ret['extra'] = $tmp;
     Yii::info($ret);
     return $ret;
 }
开发者ID:KKRainbow,项目名称:ngpt_seed,代码行数:42,代码来源:SeedController.php


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