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


PHP Credentials::getUserID方法代碼示例

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


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

示例1: login

 /**
  * 
  * Authenticates the user using the supplied credentials.
  * If workspace is recognized as the name of an existing workspace in the repository and authorization to access that workspace is granted, then a new Session object is returned.
  * If authentication or authorization for the specified workspace fails, a LoginException is thrown.
  * If workspace is not recognized, a NoSuchWorkspaceException is thrown.
  * @param Credentials $credentials the credentials of the user.
  * @param string $workspace the name of the workspace.
  * @return Session a valid session for the user to access the repository.
  *  
  */
 public static function login(Credentials $credentials, $workspace)
 {
     if (!file_exists($_SERVER['PCR'] . "/config/{$workspace}.xml")) {
         throw new NoSuchWorkspaceException($workspace);
     }
     $config = simplexml_load_file($_SERVER['PCR'] . "/config/{$workspace}.xml");
     $persistenceManager = (string) $config->persistenceManager;
     if (!file_exists($_SERVER['PCR'] . "/PMs/{$persistenceManager}.php")) {
         throw new RepositoryException("persistence manager does not exist for workspace: {$workspace}=>{$persistenceManager}");
     }
     require_once $_SERVER['PCR'] . "/PMs/{$persistenceManager}.php";
     $pm = new $persistenceManager($credentials, $workspace, $config);
     if (!$pm->isLive()) {
         throw new LoginException("workspace=>{$workspace}, persistenceManager=>{$persistenceManager}, userID=>" . $credentials->getUserID());
     }
     Log4PCR::access("workspace=>{$workspace}, persistenceManager=>{$persistenceManager}, userID=>" . $credentials->getUserID());
     return new Session($pm);
 }
開發者ID:samueljwilliams,項目名稱:pcr,代碼行數:29,代碼來源:Repository.php

示例2: __construct

 public function __construct(Credentials $credentials, $workspace, $config)
 {
     $link = @mysql_connect($config->server, $credentials->getUserID(), $credentials->getPassword(), 1);
     if (mysql_stat($link) !== null) {
         if (!mysql_select_db($workspace, $link)) {
             $sql = "CREATE DATABASE {$workspace}";
             if (mysql_query($sql, $link)) {
                 mysql_select_db($workspace, $link);
                 $sql = "CREATE TABLE c (p text NOT NULL,\n\t\t\t\t\t\t\t\tn text NOT NULL,\n\t\t\t\t\t\t\t\tv text NOT NULL,\n\t\t\t\t\t\t\t\tKEY INDEX1 (p (1000)),\n\t\t\t\t\t\t\t\tKEY INDEX2 (p (850), n (150)),\n\t\t\t\t\t\t\t\tKEY INDEX3 (p (550), n (150), v (300)),\n\t\t\t\t\t\t\t\tKEY INDEX4 (v (1000)))\n\t\t\t\t\t\t\t\tENGINE = MyISAM DEFAULT CHARSET = latin1";
                 mysql_query($sql, $link);
             } else {
                 throw new RepositoryException("in MySQL, cannot create workspace: {$workspace}");
             }
         }
         $this->credentials = $credentials;
         $this->workspace = $workspace;
         $this->config = $config;
         $this->link = $link;
         $this->isLive = true;
     }
 }
開發者ID:samueljwilliams,項目名稱:pcr,代碼行數:21,代碼來源:MySQLPersistenceManager.php


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