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


PHP Relationship::model方法代码示例

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


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

示例1: add

 public function add($user_follow, $user_followed, $type)
 {
     $check = Relationship::model()->findAllByAttributes(array('user_id_1' => $user_follow, 'user_id_2' => $user_followed));
     $check_2 = Relationship::model()->findAllByAttributes(array('user_id_2' => $user_follow, 'user_id_1' => $user_followed));
     $check_3 = Follow::model()->findByAttributes(array('user_follow' => $user_follow, 'user_followed' => $user_followed));
     if ($check || $check_2 || $check_3 || $user_followed == Yii::app()->session['user_id']) {
         return FALSE;
     }
     $model = new Follow();
     $model->user_follow = $user_follow;
     $model->user_followed = $user_followed;
     $model->created_at = time();
     $model->update_at = time();
     $model->type = $type;
     $user_follow_data = User::model()->findByPk($user_follow);
     $user_followed_data = User::model()->findByPk($user_followed);
     if ($user_follow != Yii::app()->session['user_id']) {
         $arr_noti = array('user_id' => $user_follow, 'content' => "{$user_follow_data->username} vừa theo dõi bạn", 'type' => 'follow', 'recipient_id' => $user_followed_data->id, 'url' => Yii::app()->createAbsoulteUrl('user/profile', array('user_id' => $user_follow_data->id, 'ref' => 'noti')));
         Notifications::model()->add($arr_noti);
     }
     if ($model->save(FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:huynt57,项目名称:fashion,代码行数:25,代码来源:Follow.php

示例2: actionProfile

 public function actionProfile()
 {
     try {
         $is_followed = FALSE;
         $request = Yii::app()->request;
         if ($request->getQuery('ref_api') == Yii::app()->params['REF_API']) {
             $user_id = $request->getQuery('user_id');
         } else {
             if ($request->getQuery('ref_web') == 'ref_web') {
                 $user_id = $request->getQuery('user_id');
             } else {
                 $user_id = Yii::app()->session['user_id'];
             }
         }
         $data = User::model()->getProfile($user_id);
         $posts = Posts::model()->getPostByUserForWeb($user_id);
         if ($user_id != Yii::app()->session['user_id']) {
             $check_block = Relationship::model()->findByAttributes(array('user_id_2' => Yii::app()->session['user_id'], 'user_id_1' => $user_id, 'user_type' => 'USER'));
             $is_followed = User::model()->isFollowedByUser(Yii::app()->session['user_id'], $user_id, 'USER');
             if ($check_block) {
                 return;
             }
         }
         $arr = array('profile' => $data, 'posts' => $posts['data'], 'pages' => $posts['pages'], 'is_followed' => $is_followed);
         if ($request->getQuery('ref_api') == Yii::app()->params['REF_API']) {
             ResponseHelper::JsonReturnSuccess($arr, 'Success');
         } else {
             $this->render('profile', $arr);
         }
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
开发者ID:huynt57,项目名称:fashion,代码行数:33,代码来源:UserController.php

示例3: blockUser

 public function blockUser($user_block, $user_blocked)
 {
     $model = Relationship::model()->findByAttributes(array('user_id_1' => $user_block, 'user_id_2' => $user_blocked));
     if ($model) {
         return 1;
     } else {
         $rel = new Relationship();
         $rel->user_id_1 = $user_block;
         $rel->user_id_2 = $user_blocked;
         $rel->status = 1;
         $rel->created_at = time();
         $rel->updated_at = time();
         $rel->type = Yii::app()->params['USER_BLOCK'];
         if ($rel->save(FALSE)) {
             return 2;
         } else {
             return 0;
         }
     }
 }
开发者ID:huynt57,项目名称:image_chooser,代码行数:20,代码来源:User.php

示例4: array

		<?php 
echo $form->error($model, 'related_doi');
?>
                </div>
	</div>

	<div class="control-group">
		<?php 
echo $form->labelEx($model, 'relationship', array('class' => 'control-label'));
?>
				<div class="controls">
		<?php 
//echo $form->textField($model,'relationship',array('size'=>30,'maxlength'=>30));
?>
		<?php 
echo CHtml::activeDropDownList($model, 'relationship_id', CHtml::listData(Relationship::model()->findAll(), 'id', 'name'));
?>
		<?php 
echo $form->error($model, 'relationship_id');
?>
                </div>
	</div>

	<div class="pull-right">
        <a href="/adminRelation/admin" class="btn">Cancel</a>
		<?php 
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('class' => 'btn'));
?>
	</div>

<?php 
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:31,代码来源:_form.php

示例5: getBlockedUserByUser

 public function getBlockedUserByUser($user_id)
 {
     $blocked_user_criteria = new CDbCriteria();
     $blocked_user_criteria->select = 'user_id_2';
     $blocked_user_criteria->condition = 'user_id_1=:user_id';
     $blocked_user_criteria->params = array(':user_id' => $user_id);
     $blocked_user = Relationship::model()->findAll($blocked_user_criteria);
     //return implode(',', $blocked_user);
     $returnArr = array();
     foreach ($blocked_user as $item) {
         $returnArr[] = $item->user_id_2;
     }
     return $returnArr;
 }
开发者ID:huynt57,项目名称:image_chooser,代码行数:14,代码来源:Posts.php


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