當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。