1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace Cas\Dao;
- /**
- * kif权限管理系统 - 用户所属组类
- * @author lishumingoo@gmail.com
- */
- use KIF\Verify;
- use KIF\Dao\DBAgileDev;
- class KifUsergroupRelation extends DBAgileDev {
- /**
- * 数据表名
- * @var string
- */
- protected $tableName = 'kif_usergroup_relation';
-
- /**
- * 表的主键名。默认为id
- * @var string
- */
- protected $primaryKey = 'id';
-
- /**
- * 数据库里的真实字段
- * @var array
- */
- protected $other_field = array(
- 'uid',
- 'groupid',
- );
-
- public function __construct($master_flag = 'backend') {
- parent::__construct($master_flag);
- }
-
- /**
- * 获取用户所属的组id集合
- * @param int $uid
- * @return array
- */
- public function getsGroupids($uid) {
- if (!Verify::unsignedInt($uid)) {
- return array();
- }
-
- $groupids = array();
-
- $relations = $this->findBy(array('uid' => $uid));
- if ($relations) foreach ($relations as $tmprow) {
- $groupids[] = $tmprow['groupid'];
- }
-
- return array_unique($groupids);
- }
-
- }
|