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