CAS_Client::setPGTStorageDb PHP Method

setPGTStorageDb() public method

This method is used to tell phpCAS to store the response of the CAS server to PGT requests in a database.
public setPGTStorageDb ( string $dsn_or_pdo, string $username = '', string $password = '', string $table = '', string $driver_options = null ) : void
$dsn_or_pdo string a dsn string to use for creating a PDO object or a PDO object
$username string the username to use when connecting to the database
$password string the password to use when connecting to the database
$table string the table to use for storing and retrieving PGTs
$driver_options string any driver options to use when connecting to the database
return void
    public function setPGTStorageDb($dsn_or_pdo, $username = '', $password = '', $table = '', $driver_options = null)
    {
        // Sequence validation
        $this->ensureIsProxy();
        // Argument validation
        if (is_object($dsn_or_pdo) && !$dsn_or_pdo instanceof PDO || gettype($dsn_or_pdo) != 'string') {
            throw new CAS_TypeMismatchException($dsn_or_pdo, '$dsn_or_pdo', 'string or PDO object');
        }
        if (gettype($username) != 'string') {
            throw new CAS_TypeMismatchException($username, '$username', 'string');
        }
        if (gettype($password) != 'string') {
            throw new CAS_TypeMismatchException($password, '$password', 'string');
        }
        if (gettype($table) != 'string') {
            throw new CAS_TypeMismatchException($table, '$password', 'string');
        }
        // create the storage object
        $this->setPGTStorage(new CAS_PGTStorage_Db($this, $dsn_or_pdo, $username, $password, $table, $driver_options));
    }

Usage Example

示例#1
0
文件: CAS.php 项目: DCUnit711/Demeter
 /**
  * This method is used to tell phpCAS to store the response of the
  * CAS server to PGT requests in a database.
  *
  * @param string $dsn_or_pdo     a dsn string to use for creating a PDO
  * object or a PDO object
  * @param string $username       the username to use when connecting to the
  * database
  * @param string $password       the password to use when connecting to the
  * database
  * @param string $table          the table to use for storing and retrieving
  * PGT's
  * @param string $driver_options any driver options to use when connecting
  * to the database
  *
  * @return void
  */
 public static function setPGTStorageDb($dsn_or_pdo, $username = '', $password = '', $table = '', $driver_options = null)
 {
     phpCAS::traceBegin();
     phpCAS::_validateProxyExists();
     try {
         self::$_PHPCAS_CLIENT->setPGTStorageDb($dsn_or_pdo, $username, $password, $table, $driver_options);
     } catch (Exception $e) {
         phpCAS::error(get_class($e) . ': ' . $e->getMessage());
     }
     phpCAS::traceEnd();
 }
CAS_Client