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


PHP User::insert方法代码示例

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


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

示例1: actionAdd

 public function actionAdd($password, $discuz_uid, $type = 'User')
 {
     //TODO 这个之后一定要写进配置文件而非硬编码
     if ($password !== 'ngpt_2333') {
         Yii::warning("Wrong Password!!!!!!" . $password . "uid : {$discuz_uid}");
         return ['result' => 'failed', 'extra' => 'wrong password'];
     }
     if (is_numeric($discuz_uid) && intval($discuz_uid) <= 0) {
         Yii::warning("uid not a number : {$discuz_uid}");
         return ['result' => 'failed', 'extra' => 'discuz_uid should be numeric'];
     }
     $discuz_uid = intval($discuz_uid);
     /** @var User $user */
     $user = User::findOne(['discuz_user_id' => $discuz_uid]);
     if (!empty($user)) {
         return ['result' => 'succeed', 'extra' => $user->passkey];
     }
     $user = new User();
     $user->discuz_user_id = $discuz_uid;
     $user->passkey = User::genPasskey();
     Yii::info($user->attributes);
     if ($user->insert()) {
         return ['result' => 'succeed', 'extra' => $user->passkey];
     } else {
         Yii::warning("Insert to user table failed");
         return ['result' => 'failed', 'extra' => 'Database error'];
     }
 }
开发者ID:KKRainbow,项目名称:ngpt_seed,代码行数:28,代码来源:UserController.php

示例2: actionUser

    public function actionUser()
    {
        User::deleteAll();
        $this->fdb->createCommand('DELETE FROM ngpt_ngpt_user')->query();
        //获取所有的User
        $offset = 0;
        $limit = 1000;
        QUERY:
        $sql = <<<SQL
SELECT u.*,m.adminid FROM ngpt_ngpt_users u
LEFT JOIN ngpt_common_member m ON u.uid=m.uid
LIMIT {$limit} OFFSET {$offset};
SQL;
        $res = $this->fdb->createCommand($sql)->queryAll();
        foreach ($res as $ouser) {
            $user = new User();
            $user->stat_up = $ouser['uploaded'];
            $user->stat_down = $ouser['downloaded'];
            $user->real_up = $ouser['realup'];
            $user->real_down = $ouser['realdown'];
            $user->is_valid = $ouser['candownload'] == '1';
            $user->passkey = $ouser['passkey'];
            $user->discuz_user_id = $ouser['uid'];
            if ($ouser['adminid'] != 0) {
                $user->priv = 'Admin';
            }
            var_dump($ouser);
            if (!$user->insert()) {
                var_dump($user->errors);
                return;
            }
            //进行ngpt的数据迁移
            $msql = <<<SQL
INSERT INTO ngpt_ngpt_user(uid, passkey, candownload)
VALUES ({$ouser['uid']},"{$user->passkey}", {$user->is_valid});
SQL;
            $res = $this->fdb->createCommand($msql)->query();
            if (!$res) {
                var_dump($msql);
                return;
            }
        }
        if (count($res)) {
            $offset += $limit;
            goto QUERY;
        }
        return;
    }
开发者ID:KKRainbow,项目名称:ngpt_seed,代码行数:48,代码来源:TransferController.php

示例3: RegisterNewUser

 public function RegisterNewUser($mobile, $password, $salt)
 {
     date_default_timezone_set('Asia/Shanghai');
     $registerTime = date('Y-m-d H:i:s', time());
     $user = new User();
     $user->nickName = $mobile;
     $user->password = $password;
     $user->mobile = $mobile;
     $user->registerTime = $registerTime;
     $user->lastLoginTime = $registerTime;
     $user->salt = $salt;
     $user->insert();
 }
开发者ID:jaybril,项目名称:www.mimgpotea.com,代码行数:13,代码来源:User.php


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