當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。