参数
- string
$storageDriver
要使用的存储驱动程序的名称,你可以通过自定义Auth_Container对象进行选择。
- mixed
$options
由贮藏容器设置的选项。
- string
$loginFunction
用户自定义显示登录界面的函数的名称。
- boolean
$showLogin
定义登录是否可选择的
例子
例子 21-1. 使用不同的 DB 参数 <?php
require_once "Auth/Auth.php";
function myOutput($username, $status)
{
... /** See example 1 for the full listing */
}
$params = array(
"dsn" => "mysql://martin:test@localhost/auth",
"table" => "myAuth",
"usernamecol" => "myUserColumn",
"passwordcol" => "myPasswordColumn"
);
$a = new Auth("DB", $params, "myOutput");
$a->start();
if ($a->getAuth()) {
echo "You have been authenticated successfully.";
}
?> |
|
这个例子告诉你怎样才能指定数据库表的名字和列的名字。在我们的例子中,我们使用了表myUser,从字段myUserColumn中选择username,从字段myPasswordColumn中选择password。这些字段的默认值是auth, username and password。注意 你也可以指定已存在的给定了DNS参数的DB对象,而不是一个DNS。
如果你想在PEAR::Auth使用与默认不同的数据层这些特性是必须的
例子
例子 21-2. 使用不同的DB参数 <?php
require_once "Auth/Auth.php";
function myOutput($username, $status)
{
... /** See example 1 for the full listing */
}
$a = new Auth(new CustomAuthContainer($options), null, "myOutput");
$a->start();
if ($a->getAuth()) {
echo "You have been authenticated successfully.";
}
?> |
|
这个例子告诉你怎样才能把你自己的贮藏容器传递给Auth。
如果Auth提供的贮藏容器不能满足你的要求,你可以很容易地创建你自己的贮藏容器。更多的信息请阅读贮藏容器的章节.
介绍-存储驱动