一、調用方式
$this->load->model('sns_model'); //引用時需要加載sns模型類,只加載一次即可 $this->sns_model->following($ta_uid, $my_uid);
二、參數值
參數 | 介紹 |
---|---|
$ta_uid | 關注Ta的uid |
$my_uid | 我的Uid |
三、返回值
0 關注失敗
1 關注成功
2 相互關注
-1 取消關注
四、開發示例
1、通過類方法的方式來關注
// .... public function guanzhu($ta_uid, $my_uid) { $this->load->model('sns_model'); $rt = $this->sns_model->following($ta_uid, $my_uid); if ($rt == 1) { return '關注成功'; } elseif ($rt == 2) { return '相互關注'; } elseif ($rt == -1) { return '取消關注'; } else { return '關注失敗'; } } ......
2、通過url方式來關注
創建文件/member/controllers/guanzhu.php
class Guanzhu extends M_Controller { public function __construct() { parent::__construct(); } public function index() { $ta_uid = $this->input->get('uid'); if (!$this->uid) { $this->member_msg('您尚未登錄,無法關注對方'); } $this->load->model('sns_model'); $rt = $this->sns_model->following($ta_uid, $this->uid); if ($rt == 1) { $this->member_msg('關注成功', '', 1); } elseif ($rt == 2) { $this->member_msg('相互關注', '', 1); } elseif ($rt == -1) { $this->member_msg('取消關注', '', 1); } else { $this->member_msg('關注失敗'); } } }
關注鏈接為:{MEMBER_URL}index.php?c=guanzhu&uid={關注對象的uid}
文檔最后更新時間:2014-12-28 15:13:12