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


PHP CDatabase::getDatabase方法代码示例

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


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

示例1: change

 public function change($parameter_a)
 {
     $product_list = $parameter_a['product_list'] ? $parameter_a['product_list'] : "a:0:{}";
     /*
      * $db = CDatabase::getInstance();
      * $db->query("update sk_admin_group set gname='{$parameter_a['roleName']}',rightList='{$parameter_a['rights']}',product_list='{$product_list}',parent_id='{$parameter_a['parent_id']}' where gid='{$parameter_a['id']}'");
      */
     try {
         $pdo = CDatabase::getDatabase();
         $pdo_runObject = $pdo->prepare("update sk_admin_group set gname=?,rightList=?,product_list=?,parent_id=? where gid=?");
         $pdo_runObject->bindParam(1, $parameter_a['roleName'], PDO::PARAM_STR);
         $pdo_runObject->bindParam(2, $parameter_a['rights'], PDO::PARAM_STR);
         $pdo_runObject->bindParam(3, $product_list, PDO::PARAM_STR);
         $pdo_runObject->bindParam(4, $parameter_a['parent_id'], PDO::PARAM_STR);
         $pdo_runObject->bindParam(5, $parameter_a['id'], PDO::PARAM_INT);
         $result_status = $pdo_runObject->execute();
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
     return $result_status;
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:21,代码来源:adminUserGroupModel.php

示例2: save

 /**
  * 保存对象
  */
 public function save()
 {
     $publicAttributeList = $this->_getAllSetAttribute();
     $tableName = $this->_getTableName();
     $condition = $this->condition;
     $params = $this->params;
     $where = $this->where;
     if (!empty($condition)) {
         $updateStr = '';
         foreach ($publicAttributeList as $key => $val) {
             $updateStr .= '`' . $key . '` = \'' . $val . '\' ,';
         }
         $updateStr = substr($updateStr, 0, -1);
         $dbConfig = CDatabase::$configData[1];
         $tablePre = isset($dbConfig['tablePrefix']) ? $dbConfig['tablePrefix'] : '';
         $updateSql = 'UPDATE `' . $tablePre . $tableName . '` SET ' . $updateStr . ' WHERE ' . $condition;
         $result = CDatabase::getDatabase()->prepare($updateSql)->execute($params);
         if (!$result) {
             throw new CDbException('[查询错误]调用ActiveRecord->save()方法时,执行SQL错误[' . $updateSql . ']');
         }
     } else {
         if (!empty($where)) {
             $result = CDatabase::getInstance()->update()->from($tableName)->value($publicAttributeList)->where($where)->execute();
         } else {
             $result = CDatabase::getInstance()->insert()->from($tableName)->value($publicAttributeList)->execute();
         }
     }
     //$this->_clearAttribute();
     return $result;
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:33,代码来源:CActiveRecord.php

示例3: rollback

 /**
  * 回滚一个事物
  */
 public function rollback()
 {
     //使用主库
     $databaseObject = CDatabase::getDatabase($this->configName, true);
     return $databaseObject->rollback();
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:9,代码来源:CBuilder.php

示例4: Action_delRights

 /**
  * 删除资源
  */
 public function Action_delRights()
 {
     $id = $this->Args('id', 'int');
     $status = CModel::factory('adminRightsModel')->delete(array('id' => $id));
     if (false == $status) {
         $errorMessage = CDatabase::getDatabase()->errorInfo();
         $errorMessage = isset($errorMessage[2]) ? $errorMessage[2] : '';
     }
     $this->displayAjax($status, $errorMessage);
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:13,代码来源:adminRole.php

示例5: change

 public function change($parameter_a)
 {
     $db = CDatabase::getDatabase();
     // $prepare_re=$db->prepare("update sk_admin_user set username = :username ,email = :email ,status=:status,groupId=:groupId,phone=:phone,truename=:truename where id=:id");
     if (isset($parameter_a['password']) && $parameter_a['password'] != "") {
         $prepare_re = $db->prepare("update sk_admin_user set username = ?,password = ?,email= ?,status= ?,groupId= ?,phone= ?,truename=? where id=?");
         $prepare_re->bindParam(1, $parameter_a['username'], PDO::PARAM_STR);
         $prepare_re->bindParam(2, md5($parameter_a['password']), PDO::PARAM_STR);
         $prepare_re->bindParam(3, $parameter_a['email'], PDO::PARAM_STR);
         $prepare_re->bindParam(4, $parameter_a['status'], PDO::PARAM_STR);
         $prepare_re->bindParam(5, $parameter_a['groupId'], PDO::PARAM_INT);
         $prepare_re->bindParam(6, $parameter_a['phone'], PDO::PARAM_STR);
         $prepare_re->bindParam(7, $parameter_a['truename'], PDO::PARAM_STR);
         $prepare_re->bindParam(8, $parameter_a['id'], PDO::PARAM_STR);
     } else {
         $prepare_re = $db->prepare("update sk_admin_user set username = :username ,email = :email ,status= :status ,groupId= :groupId,phone= :phone,truename= :truename where id= :id");
         $prepare_re->bindParam(":username", $parameter_a['username'], PDO::PARAM_STR);
         $prepare_re->bindParam(":email", $parameter_a['email'], PDO::PARAM_STR);
         $prepare_re->bindParam(":status", $parameter_a['status'], PDO::PARAM_STR);
         $prepare_re->bindParam(":groupId", $parameter_a['groupId'], PDO::PARAM_INT);
         $prepare_re->bindParam(":phone", $parameter_a['phone'], PDO::PARAM_STR);
         $prepare_re->bindParam(":truename", $parameter_a['truename'], PDO::PARAM_STR);
         $prepare_re->bindParam(":id", $parameter_a['id'], PDO::PARAM_STR);
     }
     $result = $prepare_re->execute();
     return $result;
 }
开发者ID:seiven,项目名称:ACEAdminForMyframework,代码行数:27,代码来源:adminUserModel.php


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