PHP Method User::findByPk, codiad Code Examples

This page contains top rated real world PHP examples of method User::findByPk from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: DefaultController.php Project: shunwusong/timer
0
 public function actionIndex()
 {
     //		$this->render('index');
     if (!empty($_GET['user'])) {
         if (is_numeric($_GET['user'])) {
             $user_id = intval($_GET['user']);
             $user = new User();
             //                var_dump($user);
             $user_info = $user->findByPk($user_id);
             //                $user_info=$user->find('id=:id',array(':id'=>$user_id));
             //                var_dump($user_info);
             //                $needing_get=NeedingGet::model()->findAll('username=:username',array(':username'=>Yii::app()->user->name));
             $needingGetCount = NeedingGet::model()->count('username=:username', array(':username' => Yii::app()->user->name));
             $neededGetCount = NeedingGet::model()->count('push_user=:username', array(':username' => Yii::app()->user->name));
             $starCount = Yii::app()->db->createCommand("select sum(star) as star_sum from needingGet where username=:username")->query(array(':username' => Yii::app()->user->name))->readAll();
             $from_count = empty($_GET['page']) || !is_numeric($_GET['page']) ? 0 : $_GET['page'];
             $page_size = 10;
             $needing_get = Yii::app()->db->createCommand("select * from needingget as A left join needing as B on A.needing_id=B.id limit {$from_count},{$page_size}")->queryAll();
             if (!empty($_GET['action']) && $_GET['action'] == 'more') {
                 echo json_encode($needing_get);
                 exit;
             }
             $this->render('index', array('user' => $user_info, 'needing_get' => $needing_get, 'needingGetCount' => $needingGetCount, 'starSum' => $starCount[0], 'neededGetCount' => $neededGetCount));
             exit;
         }
     }
 }
Example #2
Show file File: InfoController.php Project: vangogogo/justsns
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $model = new User();
     $uid = Yii::app()->user->id;
     $form = $model->findByPk($uid);
     $form->scenario = 'base';
     $data = array('model' => $form);
     $this->render('index', $data);
 }
Example #3
Show file File: HaLogin.php Project: a303/smart_lp2
0
 public static function getUser($loginProvider, $loginProviderIdentity)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('loginProvider', $loginProvider, true);
     $criteria->compare('loginProviderIdentifier', $loginProviderIdentity, true);
     $login = new CActiveDataProvider('HaLogin', array('criteria' => $criteria));
     if ($login->itemCount == 0) {
         return null;
     } else {
         // TODO - Can't seem to get this to work with relations properly....
         $tmp = $login->getData();
         $user = new User();
         return $user->findByPk($tmp[0]->userId);
     }
 }
Example #4
Show file File: test_update.php Project: gpichurov/ittalents_season5
0
<?php

require_once '../autoload.php';
$u = User::findByPk(5);
$u->username = 'Dragan Dragnov';
$u->save();
var_dump(User::findByPk(5));
Example #5
Show file File: AppController.php Project: salem-dev-acc/yiiapp
0
 protected function addProperty($data)
 {
     $userId = Yii::app()->user->getState('id');
     $propertyModel = new Properties();
     $user2PropertyModel = new User2property();
     $userModel = new \User();
     $propertyModel->unsetAttributes();
     $data['edt'] = new CDbExpression('NOW()');
     $propertyModel->setAttributes($data);
     $result = $propertyModel->save();
     if (!$result) {
         return false;
     }
     $userName = Yii::app()->user->getState('firstname') . ' ' . Yii::app()->user->getState('lastname');
     $user2PropertyModel->unsetAttributes();
     $user2PropertyModel->setAttributes(array('userId' => $userId, 'propertyId' => $propertyModel->getAttribute('id'), 'access' => UserAccessTable::OWNER, 'status' => UserAccessTable::STATUS_ACTIVE, 'color' => 'type1', 'bookingName' => $userName));
     $result = $user2PropertyModel->save();
     if (!$result) {
         return false;
     }
     $userModel->unsetAttributes();
     $oldId = $userModel->findByPk($userId);
     $oldId = $oldId->attributes['property_id'];
     $result = $userModel->updateByPk($userId, array('property_id' => $propertyModel->getAttribute('id')));
     if (!$result) {
         return false;
     }
     $userControl = new \userControl();
     $userControl->update();
     $outputArray = array('oldId' => $oldId, 'newId' => $propertyModel->getAttribute('id'));
     return $outputArray;
 }
Example #6
Show file File: 1 - UserController.php Project: salem-dev-acc/yiiapp
0
 public function actionChangepassword()
 {
     $token = isset($_POST['token']) ? $_POST['token'] : '';
     $password = isset($_POST['password']) ? $_POST['password'] : '';
     $model = new Forgot();
     $userModel = new User();
     $isForgot = $model->findByAttributes(array('token' => $token));
     $userModel->updateByPk($isForgot->user_id, array('password' => $password));
     $isForgot->delete();
     $isFirst = false;
     if ($userModel->loginDate == null) {
         $isFirst = true;
     }
     $user = $userModel->findByPk($isForgot->user_id);
     $this->actionLogin($user->attributes['email'], $user->attributes['password'], $isFirst);
 }
Example #7
Show file File: IndexController.php Project: biggtfish/A-Simple-CMS
0
 public function actionT($uid, $id)
 {
     $this->Myaccess($uid);
     //加载布局uid
     $this->uid = $uid;
     $data = array('uid' => $uid, 'url' => "http://" . Yii::app()->params['bucket'] . "." . Yii::app()->params['domain'] . "/");
     //关于我
     $userModel = new User();
     $data['userInfo'] = $userModel->findByPk($uid);
     //相册
     $photoModel = new Photo();
     $sql = "select * from {{photo}} where userid = {$uid} order by rand() limit 0,6";
     $data['photoInfo'] = $photoModel->findAllBySql($sql);
     //标签
     $data['labelInfo'] = $this->GetTags($uid);
     //文章列表
     $cutSize = 200;
     //截取字符数
     $sql = "select b.*,b.id as bid,l.label,u.* from {{user}} u, {{blog}} b,{{label}} l where b.userid = {$uid} and b.userid = u.id and b.labelid = l.id ";
     $order = " order by b.time desc  ";
     if ($id != "all") {
         $sql = $sql . "and b.labelid = {$id} " . $order;
     } else {
         $sql = $sql . $order;
     }
     $criteria = new CDbCriteria();
     $result = Yii::app()->db->createCommand($sql)->query();
     $pages = new CPagination($result->rowCount);
     $pages->pageSize = Yii::app()->params['blogCount'];
     $pages->applyLimit($criteria);
     $result = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit");
     $result->bindValue(':offset', $pages->currentPage * $pages->pageSize);
     $result->bindValue(':limit', $pages->pageSize);
     $blogs = $result->queryAll();
     /**
      * 结果集处理
      * 1.图片缩放
      * 2.截取文字
      */
     foreach ($blogs as $key => $b) {
         $blogs[$key]['image'] = GetImageFileName($b['image']);
         $blogs[$key]['content'] = Helper::WordTruncate(strip_tags($b['content']), $cutSize, false);
     }
     //分两种方式显示
     $data['pages'] = $pages;
     $data['blogs'] = $blogs;
     $this->render('index', $data);
 }
Example #8
Show file File: IndexController.php Project: returncn/chen-xia-cms
0
 public function actionM($who)
 {
     $uid = $who;
     $this->Myaccess($uid);
     $this->uid = $uid;
     $userExists = new User();
     $User = $userExists->findByPk($uid);
     if ($User == NULL) {
         $data['message'] = "~Sorry,你貌似跑到火星上去了,那儿木有你找的人,请速回地球吧# ~";
         $data['backup'] = "/index/index";
         $data['params'] = array();
         $this->layout = "//layouts/error";
         $this->render("error", $data);
         die;
     }
     $data = array('uid' => $uid, 'url' => Yii::app()->params['resurl']);
     $data = array_merge($data, $this->getUinfo($uid));
     $this->layout = "//layouts/empty";
     $this->render('index', $data);
 }
Example #9
Show file File: test_delete.php Project: gpichurov/ittalents_season5
0
<?php

require_once '../autoload.php';
$u = User::findByPk(11);
$u->delete();
var_dump(User::findByPk(11));
echo implode('<br>', Logger::flush());
Example #10
Show file File: test_find_by_pk.php Project: gpichurov/ittalents_season5
0
<?php

require_once '../autoload.php';
$u = User::findByPk(5);
var_dump($u);