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


PHP CDatabase::getInstance方法代码示例

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


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

示例1: filterCanAddRole

 /**
  * 可添加的角色组
  */
 public function filterCanAddRole($list)
 {
     $userData = CSession::get('user');
     $groupId = $userData['groupData']['gid'];
     // 超级管理员给全部资源
     if (1 == $groupId) {
         return $list;
     }
     $category = CDatabase::getInstance()->from('admin_group')->select()->execute()->asArray();
     foreach ($category as $key => $val) {
         $category[$key]['name'] = $val['gname'];
         $category[$key]['id'] = $val['gid'];
     }
     $category = TreeClass::getTree($category);
     // 获取其子类
     $childData = $childDataVal = array();
     TreeClass::getCatTree($groupId, $category, $childData, $childDataVal);
     foreach ($list as $key => $val) {
         if (!in_array($val['gid'], $childData)) {
             unset($list[$key]);
         }
     }
     return $list;
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:27,代码来源:adminRoleModel.php

示例2: getGroupList

 /**
  * 获取所有用户名 以gid排序
  */
 public function getGroupList()
 {
     return CDatabase::getInstance()->from($this->tableName())->select()->execute()->getKey('gid');
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:7,代码来源:adminUserGroupModel.php

示例3: delete

 /**
  * 删除记录
  */
 public function delete($where)
 {
     try {
         $tableName = $this->tableName();
         $data = CDatabase::getInstance()->delete()->from($tableName)->where($where)->execute();
         return $data->isSuccess();
     } catch (CDbException $e) {
         $this->_lastError = $e->getMessage();
         return false;
     }
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:14,代码来源:CActiveRecord.php

示例4: Action_userList

 /**
  * 用户管理
  */
 public function Action_userList()
 {
     $where['gid'] = $this->Args('gid', 'int');
     $where['username'] = $this->Args('username');
     // 用户
     $list = CDatabase::getInstance()->from('admin_user')->select()->limit(50000);
     if (!empty($where['gid']) && $where['gid'] != '-1') {
         $list = $list->where('groupId', '=', $where['gid']);
     }
     if (!empty($where['username'])) {
         $list = $list->where('username', 'LIKE', '%' . $where['username'] . '%');
     }
     $list = $list->execute()->asArray();
     // 过滤用户
     $list = CModel::factory('adminUserModel')->filterUser($list);
     // 组
     $group = CModel::factory('adminRoleModel')->findAll()->asArray();
     $groupKeyArr = array();
     foreach ($group as $val) {
         $groupKeyArr[$val['gid']] = $val;
     }
     $canGroup = CModel::factory('adminRoleModel')->findAll()->asArray();
     $canGroup = CModel::factory('adminRoleModel')->filterCanAddRole($group);
     $this->assign('where', $where);
     $this->assign('canGroup', $canGroup);
     $this->assign('list', $list);
     $this->assign('group', $groupKeyArr);
     $this->display();
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:32,代码来源:adminRole.php

示例5: filterUser

 /**
  * 过滤权限
  */
 public function filterUser($list)
 {
     $userData = CSession::get('user');
     $groupId = $userData['groupData']['gid'];
     if (1 == $groupId) {
         return $list;
     }
     $category = CDatabase::getInstance()->from('admin_group')->select()->execute()->asArray();
     foreach ($category as $key => $val) {
         $category[$key]['name'] = $val['gname'];
         $category[$key]['id'] = $val['gid'];
     }
     $category = TreeClass::getTree($category);
     // 获取该组ID阔以查看的所有子组ID
     $childData = $childDataVal = array();
     TreeClass::getCatTree($groupId, $category, $childData, $childDataVal);
     // 可以查询的子组ID序列
     $groupList = array();
     foreach ($childDataVal as $key => $val) {
         $groupList[] = $val['gid'];
     }
     foreach ($list as $key => $val) {
         if (!in_array($val['groupId'], $groupList)) {
             unset($list[$key]);
         }
     }
     return $list;
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:31,代码来源:adminUserModel.php

示例6: getCount

 public function getCount($setWhere)
 {
     $list = CDatabase::getInstance()->from($this->tableName())->select(array("count(`{$this->pkName()}`)" => 'num'));
     // 筛选条件
     $list = $this->setWhere($list, $setWhere);
     $list = $list->execute()->current();
     return isset($list['num']) ? $list['num'] : 0;
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:8,代码来源:adminRightsModel.php


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