當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::setDefaultDatabase方法代碼示例

本文整理匯總了PHP中models\User::setDefaultDatabase方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setDefaultDatabase方法的具體用法?PHP User::setDefaultDatabase怎麽用?PHP User::setDefaultDatabase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models\User的用法示例。


在下文中一共展示了User::setDefaultDatabase方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: readDbFromRequest

 /**
  * Read the user belonging to the incoming request and get his/her defaultDB.
  *
  * @return String $userdb
  */
 public static function readDbFromRequest()
 {
     $app = \Slim\Slim::getInstance();
     $oUser = new User();
     $request = $app->request();
     $public_key = $request->headers('X-PublicKey');
     //get User array from sent public key
     $user = $oUser->getUserByPublicKey($public_key);
     $userdb = $oUser->setDefaultDatabase($user['LoginID']);
     if ($userdb != NULL) {
         return $userdb;
     } else {
         $response["error"] = true;
         $response["defaultdb"] = "Could not select database of user.";
         LogHelper::write("Could not select database, check if the user's DefaultDB is available.", $user['username']);
         RequestHelper::echoResponse(500, $response);
         $app->stop();
     }
 }
開發者ID:Rudianasaja,項目名稱:openMEDIS-Slim-PHP-REST-API,代碼行數:24,代碼來源:RequestHelper.php

示例2: function

use lib\LogHelper as Log;
// API Versioning
$app->group('/v1', function () use($app) {
    /**
     * GET route to export whole database to JSON
     *
     */
    $app->get('/database/export', function () use($app) {
        //create empty user
        $oUser = new User();
        //request header
        $request = $app->request();
        $public_key = $request->headers('X-PublicKey');
        //get User array from sent public key
        $user = $oUser->getUserByPublicKey($public_key);
        $userdb = $oUser->setDefaultDatabase($user['LoginID']);
        //get access level string of user
        $access_level = $oUser->getAccessLevel($user['LoginID']);
        //create new instance with the user specific database
        $tempTool = new DbExport($userdb);
        //read relevant table names with the user specific access level
        $export = $tempTool->readRelevantTables($access_level);
        $app->contentType('application/json;charset=utf-8');
        echo json_encode($export);
    });
    /**
     * GET route to export database meta information to JSON
     *
     */
    $app->get('/database/scheme', function () use($app) {
        $userdb = R::readDbFromRequest();
開發者ID:Rudianasaja,項目名稱:openMEDIS-Slim-PHP-REST-API,代碼行數:31,代碼來源:dbexport.router.php


注:本文中的models\User::setDefaultDatabase方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。